use qrandomgenerator

This commit is contained in:
Martin Rotter 2020-07-24 11:17:38 +02:00
parent fe286a707f
commit 96d94e93a4
2 changed files with 4 additions and 9 deletions

View File

@ -10,11 +10,10 @@
#include <QDir>
#include <QLocale>
#include <QRandomGenerator64>
#include <QString>
#include <QStringList>
#include <random>
quint64 TextFactory::s_encryptionKey = 0x0;
TextFactory::TextFactory() = default;
@ -163,10 +162,5 @@ quint64 TextFactory::initializeSecretEncryptionKey() {
}
quint64 TextFactory::generateSecretEncryptionKey() {
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<quint64> dist(std::numeric_limits<quint64>().min() + 1000000UL,
std::numeric_limits<quint64>().max());
return dist(mt);
return QRandomGenerator64::global()->generate();
}

View File

@ -37,6 +37,7 @@
#include <QJsonObject>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QRandomGenerator>
#include <cstdlib>
#include <utility>
@ -45,7 +46,7 @@ Q_GLOBAL_STATIC(OAuthHttpHandler, qz_silent_acmanager)
OAuth2Service::OAuth2Service(const QString& auth_url, const QString& token_url, const QString& client_id,
const QString& client_secret, const QString& scope, QObject* parent)
: QObject(parent), m_id(QString::number(std::rand())), m_timerId(-1), m_redirectionHandler(new OAuthHttpHandler(this)) {
: QObject(parent), m_id(QString::number(QRandomGenerator::global()->generate())), m_timerId(-1), m_redirectionHandler(new OAuthHttpHandler(this)) {
m_tokenGrantType = QSL("authorization_code");
m_tokenUrl = QUrl(token_url);
m_authUrl = auth_url;