예제 #1
0
void Settings::setDBServerUserPassword(const QString &userPassword){
    QByteArray *destination = new QByteArray();
    Cryptography cryptography;
    cryptography.teaCrypto(destination, userPassword.toUtf8(), key, true);
    setValue("Database/Password", *destination);
    delete destination;
}
예제 #2
0
void Settings::setRecentUserPassword(const QString &password){

    QByteArray *destination = new QByteArray();
    Cryptography cryptography;
    cryptography.teaCrypto(destination, password.toUtf8(), key, true);
    setValue("MainWindow/RecentUserPassword", *destination);
    delete destination;

}
예제 #3
0
QString Settings::getDBServerUserName() const{
    QString userName = "";
    QByteArray userNameArray = value("Database/UserName").toByteArray();
    if(userNameArray.isEmpty()){
        userName = REMOTE_SITOY_COMPUTERS_DB_USER_NAME;
    }else{
        QByteArray *destination = new QByteArray();
        Cryptography cryptography;
        cryptography.teaCrypto(destination, userNameArray, key, false);
        userName = QString(*destination);
        delete destination;

    }
    return userName;
}
예제 #4
0
QString Settings::getDBServerUserPassword() const{
    QString password = "";
    QByteArray passwordArray = value("Database/Password").toByteArray();
    if(passwordArray.isEmpty()){
        password = REMOTE_SITOY_COMPUTERS_DB_USER_PASSWORD;
    }else{
        QByteArray *destination = new QByteArray();
        Cryptography cryptography;
        cryptography.teaCrypto(destination, passwordArray, key, false);
        password = QString(*destination);
        delete destination;

    }
    return password;
}
예제 #5
0
QString Settings::getRecentUserPassword() const{

    QByteArray passwordArray = value("MainWindow/RecentUserPassword").toByteArray();
    if(!passwordArray.isEmpty()){

        QByteArray *destination = new QByteArray();
        Cryptography cryptography;
        cryptography.teaCrypto(destination, passwordArray, key, false);
        passwordArray = *destination;
        delete destination;

    }

    return QString(passwordArray);

}
예제 #6
0
bool do_test(vector<int> numbers, long long __expected) {
    time_t startClock = clock();
    Cryptography *instance = new Cryptography();
    long long __result = instance->encrypt(numbers);
    double elapsed = (double)(clock() - startClock) / CLOCKS_PER_SEC;
    delete instance;

    if (__result == __expected) {
        cout << "PASSED!" << " (" << elapsed << " seconds)" << endl;
        return true;
    }
    else {
        cout << "FAILED!" << " (" << elapsed << " seconds)" << endl;
        cout << "           Expected: " << to_string(__expected) << endl;
        cout << "           Received: " << to_string(__result) << endl;
        return false;
    }
}
예제 #7
0
double test2() {
	int t0[] = {1000,999,998,997,996,995};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	Cryptography * obj = new Cryptography();
	clock_t start = clock();
	long long my_answer = obj->encrypt(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	long long p1 = 986074810223904000LL;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p1 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p1 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
예제 #8
0
int main() {
    Cryptography test;
    long ans = test.encrypt(numbers);
    printf("%d\n", ans);
    return 0;
}