From 0071ee1f093ce4399c5fe6522485eeceb4356897 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 24 May 2020 12:35:20 +0200 Subject: [PATCH] check for wrong password --- src/mainwindow.cpp | 67 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49f4f72..ee93f6f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -466,21 +466,46 @@ void MainWindow::removeWalletEncryption() { crypto_pwhash_ALG_DEFAULT) != 0) { /* out of memory */ } + + QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat")); + filencrypted.remove(); + + { auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); - QString target_encaddr_file = dir.filePath("addresslabels.dat.enc"); - QString target_decaddr_file = dir.filePath("addresslabels.dat"); QString target_encwallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat"); QString target_decwallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"); + QString target_encaddr_file = dir.filePath("addresslabels.dat.enc"); + QString target_decaddr_file = dir.filePath("addresslabels.dat"); - FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key); FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, key); - QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat")); - filencrypted.remove(); - } + + auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat")); + + if (filencrypted.size() > 0) + { + + QMessageBox::information(this, tr("Wallet Encryption Success"), + QString("SDL is ready to Rock"), + QMessageBox::Ok + ); + }else{ + + qDebug()<<"verschlüsselung gescheitert "; + + QMessageBox::critical(this, tr("Wallet Encryption Failed"), + QString("false password please try again"), + QMessageBox::Ok + ); + this->removeWalletEncryptionStartUp(); + } + + } + } void MainWindow::removeWalletEncryptionStartUp() { @@ -532,12 +557,15 @@ void MainWindow::removeWalletEncryptionStartUp() { unsigned char key[KEY_LEN]; - if (crypto_pwhash + if (crypto_pwhash (key, sizeof key, PASSWORD, strlen(PASSWORD), hash, crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, crypto_pwhash_ALG_DEFAULT) != 0) { /* out of memory */ } + + + { auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); QString target_encwallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat"); @@ -546,8 +574,31 @@ void MainWindow::removeWalletEncryptionStartUp() { QString target_decaddr_file = dir.filePath("addresslabels.dat"); FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key); - // QThread::sleep(1); FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, key); + + } + + auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + QFile filencrypted(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat")); + + if (filencrypted.size() > 0) + { + + QMessageBox::information(this, tr("Wallet Encryption Success"), + QString("SDL is ready to Rock"), + QMessageBox::Ok + ); + }else{ + + qDebug()<<"verschlüsselung gescheitert "; + + QMessageBox::critical(this, tr("Wallet Encryption Failed"), + QString("false password please try again"), + QMessageBox::Ok + ); + this->removeWalletEncryptionStartUp(); + } + } }