forked from Public/monero-gui
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();
|
||||
|
||||
Reference in New Issue
Block a user