diff options
| author | selsta <selsta@sent.at> | 2026-01-19 19:24:10 +0100 |
|---|---|---|
| committer | selsta <selsta@sent.at> | 2026-01-19 21:24:31 +0100 |
| commit | 2ddb55059123815bebad0e3c4c0853328275f060 (patch) | |
| tree | 263c44d771d86158cfb64d59ca935e2c900d3aca /src/main | |
| parent | e984c28fafc224df0f3d9e24a3ed942af5cf929f (diff) | |
| download | monzero-gui-2ddb55059123815bebad0e3c4c0853328275f060.tar.gz monzero-gui-2ddb55059123815bebad0e3c4c0853328275f060.tar.xz monzero-gui-2ddb55059123815bebad0e3c4c0853328275f060.zip | |
WizardController: set password for temp wallet
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/oshelper.cpp | 14 | ||||
| -rw-r--r-- | src/main/oshelper.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/main/oshelper.cpp b/src/main/oshelper.cpp index d44fc8c2..2ca0e400 100644 --- a/src/main/oshelper.cpp +++ b/src/main/oshelper.cpp @@ -43,6 +43,8 @@ #include <QFileInfo> #include <QString> #include <QUrl> +#include <QByteArray> +#include <QRandomGenerator> #ifdef Q_OS_MAC #include "qt/macoshelper.h" #endif @@ -246,6 +248,18 @@ QString OSHelper::temporaryPath() const return QDir::tempPath(); } +QString OSHelper::randomPassword(int numBytes) const +{ + numBytes = qBound(16, numBytes, 128); + + QByteArray buf(numBytes, Qt::Uninitialized); + auto *rng = QRandomGenerator::system(); + for (int i = 0; i < numBytes; ++i) + buf[i] = char(rng->generate() & 0xFF); + + return QString::fromLatin1(buf.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)); +} + bool OSHelper::installed() const { #ifdef Q_OS_WIN diff --git a/src/main/oshelper.h b/src/main/oshelper.h index 4242cc05..dc3058dd 100644 --- a/src/main/oshelper.h +++ b/src/main/oshelper.h @@ -51,6 +51,7 @@ public: Q_INVOKABLE QString openSaveFileDialog(const QString &title, const QString &folder, const QString &filename) const; Q_INVOKABLE QString temporaryFilename() const; Q_INVOKABLE QString temporaryPath() const; + Q_INVOKABLE QString randomPassword(int numBytes = 32) const; Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const; Q_INVOKABLE bool isCapsLock() const; Q_INVOKABLE quint8 getNetworkTypeFromFile(const QString &keysPath) const; |
