diff --git a/build_snap.sh b/build_snap.sh index 40af747..b1f3cc9 100755 --- a/build_snap.sh +++ b/build_snap.sh @@ -74,9 +74,7 @@ fi # build libwallet ${SNAPCRAFT_PART_SRC}/get_libwallet_api.sh $BUILD_TYPE -if [ "$DISABLE_PASS_STRENGTH_METER" != true ]; then - $MAKE -C ${SNAPCRACFT_PART_SRC}/src/zxcvbn-c || exit -fi +make -C '${SNAPCRACFT_PART_SRC}/src/zxcvbn-c' if [ ! -d build ]; then mkdir build; fi diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 4b1f35d..e2b4c72 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -1,6 +1,7 @@ #include "WalletManager.h" #include "Wallet.h" #include "wallet/api/wallet2_api.h" +#include "zxcvbn-c/zxcvbn.h" #include "QRCodeImageProvider.h" #include #include @@ -301,6 +302,23 @@ QUrl WalletManager::localPathToUrl(const QString &path) const return QUrl::fromLocalFile(path); } +#ifndef DISABLE_PASS_STRENGTH_METER +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; +} +#endif + bool WalletManager::saveQrCode(const QString &code, const QString &path) const { QSize size;