mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Return password quality to keepasshttp client.
This commit is contained in:
parent
75564c8fb5
commit
b432103b82
@ -89,6 +89,22 @@ QString PasswordGenerator::generatePassword() const
|
||||
return password;
|
||||
}
|
||||
|
||||
int PasswordGenerator::getbits() const
|
||||
{
|
||||
QVector<PasswordGroup> groups = passwordGroups();
|
||||
|
||||
int bits = 0;
|
||||
QVector<QChar> passwordChars;
|
||||
Q_FOREACH (const PasswordGroup& group, groups) {
|
||||
bits += group.size();
|
||||
}
|
||||
|
||||
bits *= m_length;
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
|
||||
bool PasswordGenerator::isValid() const
|
||||
{
|
||||
if (m_classes == 0) {
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
bool isValid() const;
|
||||
|
||||
QString generatePassword() const;
|
||||
int getbits() const;
|
||||
|
||||
private:
|
||||
QVector<PasswordGroup> passwordGroups() const;
|
||||
|
@ -229,3 +229,8 @@ QString HttpSettings::generatePassword()
|
||||
|
||||
return m_generator.generatePassword();
|
||||
}
|
||||
|
||||
int HttpSettings::getbits()
|
||||
{
|
||||
return m_generator.getbits();
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
static PasswordGenerator::CharClasses passwordCharClasses();
|
||||
static PasswordGenerator::GeneratorFlags passwordGeneratorFlags();
|
||||
static QString generatePassword();
|
||||
static int getbits();
|
||||
|
||||
private:
|
||||
static PasswordGenerator m_generator;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "Server.h"
|
||||
#include <microhttpd.h>
|
||||
#include "Protocol.h"
|
||||
#include "HttpSettings.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QCryptographicHash>
|
||||
@ -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>() << Entry("generate-password", "generate-password", password, "generate-password"));
|
||||
protocolResp->setEntries(QList<Entry>() << Entry("generate-password", bits, password, "generate-password"));
|
||||
|
||||
memset(password.data(), 0, password.length());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user