diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index 5915ba898..52f124786 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -89,6 +89,22 @@ QString PasswordGenerator::generatePassword() const return password; } +int PasswordGenerator::getbits() const +{ + QVector groups = passwordGroups(); + + int bits = 0; + QVector passwordChars; + Q_FOREACH (const PasswordGroup& group, groups) { + bits += group.size(); + } + + bits *= m_length; + + return bits; +} + + bool PasswordGenerator::isValid() const { if (m_classes == 0) { diff --git a/src/core/PasswordGenerator.h b/src/core/PasswordGenerator.h index 6a9d21245..54982ac9c 100644 --- a/src/core/PasswordGenerator.h +++ b/src/core/PasswordGenerator.h @@ -55,6 +55,7 @@ public: bool isValid() const; QString generatePassword() const; + int getbits() const; private: QVector passwordGroups() const; diff --git a/src/http/HttpSettings.cpp b/src/http/HttpSettings.cpp index f98fcb7e2..4692023d1 100644 --- a/src/http/HttpSettings.cpp +++ b/src/http/HttpSettings.cpp @@ -229,3 +229,8 @@ QString HttpSettings::generatePassword() return m_generator.generatePassword(); } + +int HttpSettings::getbits() +{ + return m_generator.getbits(); +} diff --git a/src/http/HttpSettings.h b/src/http/HttpSettings.h index 5f2577c39..ba430c672 100644 --- a/src/http/HttpSettings.h +++ b/src/http/HttpSettings.h @@ -60,6 +60,7 @@ public: static PasswordGenerator::CharClasses passwordCharClasses(); static PasswordGenerator::GeneratorFlags passwordGeneratorFlags(); static QString generatePassword(); + static int getbits(); private: static PasswordGenerator m_generator; diff --git a/src/http/Server.cpp b/src/http/Server.cpp index dedbd221c..1afdd5051 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -14,6 +14,7 @@ #include "Server.h" #include #include "Protocol.h" +#include "HttpSettings.h" #include "crypto/Crypto.h" #include #include @@ -165,11 +166,12 @@ void Server::generatePassword(const Request &r, Response *protocolResp) return; QString password = generatePassword(); + QString bits = QString::number(HttpSettings::getbits()); protocolResp->setSuccess(); protocolResp->setId(r.id()); protocolResp->setVerifier(key); - protocolResp->setEntries(QList() << Entry("generate-password", "generate-password", password, "generate-password")); + protocolResp->setEntries(QList() << Entry("generate-password", bits, password, "generate-password")); memset(password.data(), 0, password.length()); }