mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-05 06:57:26 -04:00
Use zxcvbn for password strength estimation
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user