diff options
| author | moneromooo.monero <moneromooo.monero@users.noreply.github.com> | 2016-12-16 00:11:37 +0000 |
|---|---|---|
| committer | moneromooo.monero <moneromooo.monero@users.noreply.github.com> | 2016-12-17 11:32:33 +0000 |
| commit | fbe19d23b70cb051e6089128c7eec1b82589f680 (patch) | |
| tree | 43f4439d09a37c7055a9b4cf1612d6be4449b08b /src | |
| parent | b882de8e1ccfd3965eddbfb90e75b7d6d229f32c (diff) | |
| download | monzero-gui-fbe19d23b70cb051e6089128c7eec1b82589f680.tar.gz monzero-gui-fbe19d23b70cb051e6089128c7eec1b82589f680.tar.xz monzero-gui-fbe19d23b70cb051e6089128c7eec1b82589f680.zip | |
Use zxcvbn for password strength estimation
Diffstat (limited to 'src')
| -rw-r--r-- | src/libwalletqt/WalletManager.cpp | 16 | ||||
| -rw-r--r-- | src/libwalletqt/WalletManager.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 0ff8d74d..64e9a1db 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -1,6 +1,7 @@ #include "WalletManager.h" #include "Wallet.h" #include "wallet/wallet2_api.h" +#include "zxcvbn-c/zxcvbn.h" #include <QFile> #include <QFileInfo> #include <QDir> @@ -241,6 +242,21 @@ QUrl WalletManager::localPathToUrl(const QString &path) const return QUrl::fromLocalFile(path); } +double WalletManager::getPasswordStrength(const QString &password) const +{ + static const char *local_dict[] = { + "monero", "fluffypony", NULL + }; + + if (!ZxcvbnInit("zxcvbn.dict")) { + fprintf(stderr, "Failed to open zxcvbn.dict\n"); + return 0.0; + } + double e = ZxcvbnMatch(password.toStdString().c_str(), local_dict, NULL); + ZxcvbnUnInit(); + return e; +} + WalletManager::WalletManager(QObject *parent) : QObject(parent) { m_pimpl = Monero::WalletManagerFactory::getWalletManager(); diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 88425f6f..fb3dd142 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -114,6 +114,8 @@ public: Q_INVOKABLE qint64 addi(qint64 x, qint64 y) const { return x + y; } Q_INVOKABLE qint64 subi(qint64 x, qint64 y) const { return x - y; } + Q_INVOKABLE double getPasswordStrength(const QString &password) const; + signals: void walletOpened(Wallet * wallet); |
