From c6dff486433807afe61b53a6c11d968ac7a41380 Mon Sep 17 00:00:00 2001 From: Strider <127.0.0.1@404.found> Date: Sat, 23 May 2020 19:50:36 +0200 Subject: [PATCH] update// added really goody stuff :D --- src/FileSystem/FileSystem.cpp | 7 ------ src/mainwindow.cpp | 46 ++++++++++++----------------------- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/FileSystem/FileSystem.cpp b/src/FileSystem/FileSystem.cpp index 74a0440..2a60de1 100644 --- a/src/FileSystem/FileSystem.cpp +++ b/src/FileSystem/FileSystem.cpp @@ -86,13 +86,6 @@ void FileSystem::writeContactsOldFormat(QString file, QList contact QList FileSystem::readContactsOldFormat(QString file) { - const unsigned char* data=PASSWD::hash(QString("Hello world")); - PASSWD::show_hex_buff((unsigned char*) data); - QString source_file = "/tmp/addresslabels.dat"; - QString target_file = "/tmp/addresslabels.dat.enc"; - FileEncryption::encrypt(target_file, source_file, data); - FileEncryption::decrypt("/tmp/addresslabels.dat.dec", target_file, data); - QList contacts; QFile _file(file); if (_file.exists()) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9138c7c..a2566ad 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -25,6 +25,9 @@ #include "sodium.h" #include "sodium/crypto_generichash_blake2b.h" #include +#include "FileSystem/FileSystem.h" +#include "Crypto/passwd.h" +#include "Crypto/FileEncryption.h" using json = nlohmann::json; @@ -283,39 +286,20 @@ void MainWindow::encryptWallet() { QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited); QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited); - if (d.exec() == QDialog::Accepted) { - - QString str = ed.txtPassword->text(); // data comes from user inputs - int length = str.length(); - - char *sequence = NULL; - sequence = new char[length+1]; - strncpy(sequence, str.toLocal8Bit(), length +1); - - #define MESSAGE ((const unsigned char *) sequence) - #define MESSAGE_LEN length - - qDebug()<<"Generating cryptographic key from password: " <text()); + PASSWD::show_hex_buff((unsigned char*) key); + auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); + QString source_file = dir.filePath("addresslabels.dat"); + QString target_enc_file = dir.filePath("addresslabels.dat.enc"); + QString target_dec_file = dir.filePath("addresslabels.dat.dec"); + FileEncryption::encrypt(target_enc_file, source_file, key); + FileEncryption::decrypt(target_dec_file, target_enc_file, key); -d.exec(); + d.exec(); -} + } }