update// added really goody stuff :D
This commit is contained in:
@@ -86,13 +86,6 @@ void FileSystem::writeContactsOldFormat(QString file, QList<ContactItem> contact
|
|||||||
|
|
||||||
QList<ContactItem> FileSystem::readContactsOldFormat(QString file)
|
QList<ContactItem> 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<ContactItem> contacts;
|
QList<ContactItem> contacts;
|
||||||
QFile _file(file);
|
QFile _file(file);
|
||||||
if (_file.exists())
|
if (_file.exists())
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
#include "sodium/crypto_generichash_blake2b.h"
|
#include "sodium/crypto_generichash_blake2b.h"
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include "FileSystem/FileSystem.h"
|
||||||
|
#include "Crypto/passwd.h"
|
||||||
|
#include "Crypto/FileEncryption.h"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -283,39 +286,20 @@ void MainWindow::encryptWallet() {
|
|||||||
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted) {
|
if (d.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
QString str = ed.txtPassword->text(); // data comes from user inputs
|
const unsigned char* key=PASSWD::hash(ed.txtPassword->text());
|
||||||
int length = str.length();
|
PASSWD::show_hex_buff((unsigned char*) key);
|
||||||
|
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
char *sequence = NULL;
|
QString source_file = dir.filePath("addresslabels.dat");
|
||||||
sequence = new char[length+1];
|
QString target_enc_file = dir.filePath("addresslabels.dat.enc");
|
||||||
strncpy(sequence, str.toLocal8Bit(), length +1);
|
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);
|
||||||
|
|
||||||
#define MESSAGE ((const unsigned char *) sequence)
|
d.exec();
|
||||||
#define MESSAGE_LEN length
|
|
||||||
|
|
||||||
qDebug()<<"Generating cryptographic key from password: " <<sequence;
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char hash[crypto_secretstream_xchacha20poly1305_KEYBYTES];
|
|
||||||
|
|
||||||
crypto_generichash(hash, sizeof hash,
|
|
||||||
MESSAGE, MESSAGE_LEN,
|
|
||||||
NULL, 0);
|
|
||||||
|
|
||||||
|
|
||||||
qDebug()<<"secret key generated:\n";
|
|
||||||
dump_hex_buff(hash,crypto_secretstream_xchacha20poly1305_KEYBYTES);
|
|
||||||
|
|
||||||
QString source_file = "/home/denio/.local/share/Hush/SilentDragonLite/addresslabel.dat";
|
|
||||||
QString target_file = "/home/denio/.local/share/Hush/SilentDragonLite/addresslabel-encrypt.dat";
|
|
||||||
|
|
||||||
FileEncryption::encrypt(target_file, source_file, hash);
|
|
||||||
|
|
||||||
d.exec();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user