diff --git a/src/miscellaneous/textfactory.cpp b/src/miscellaneous/textfactory.cpp index 99c049621..ce4741871 100755 --- a/src/miscellaneous/textfactory.cpp +++ b/src/miscellaneous/textfactory.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -124,12 +125,19 @@ quint64 TextFactory::initializeSecretEncryptionKey() { QString encryption_file_path = qApp->settings()->pathName() + QDir::separator() + ENCRYPTION_FILE_NAME; try { - s_encryptionKey = (quint64) QString(IOFactory::readFile(encryption_file_path)).toLongLong(); + s_encryptionKey = quint64(QString(IOFactory::readFile(encryption_file_path)).toLongLong()); } catch (ApplicationException) { // Well, key does not exist or is invalid, generate and save one. s_encryptionKey = generateSecretEncryptionKey(); - IOFactory::writeFile(encryption_file_path, QString::number(s_encryptionKey).toLocal8Bit()); + + try { + IOFactory::writeFile(encryption_file_path, QString::number(s_encryptionKey).toLocal8Bit()); + } + catch (ApplicationException& ex) { + qCritical("Failed to write newly generated encryption key to file, error '%s'. Now, your passwords won't be " + "readable after you start this application again.", qPrintable(ex.message())); + } } } @@ -137,5 +145,5 @@ quint64 TextFactory::initializeSecretEncryptionKey() { } quint64 TextFactory::generateSecretEncryptionKey() { - return RAND_MAX * qrand() + qrand(); + return QRandomGenerator().generate64(); } diff --git a/src/network-web/downloader.cpp b/src/network-web/downloader.cpp index ef6b50794..394f693db 100755 --- a/src/network-web/downloader.cpp +++ b/src/network-web/downloader.cpp @@ -175,8 +175,6 @@ void Downloader::progressInternal(qint64 bytes_received, qint64 bytes_total) { QList Downloader::decodeMultipartAnswer(QNetworkReply* reply) { QByteArray data = reply->readAll(); - IOFactory::writeFile("b.json", data); - if (data.isEmpty()) { return QList(); }