/** Checks equality between a clear password \e clear and
 * a crypted password (in base64 encoding) \e cryptedBase64.
 * The crypted password must have been created using the
 * cryptPassword().
 */
bool PasswordCrypter::checkPassword(const QString &clear, const QString &cryptedBase64)
{
    // Get the prefixed algorithm
    Algorithm algo = SHA1;
    if (cryptedBase64.contains(":")) {
        algo = extractHashAlgorithm(cryptedBase64);
    }
    QString crypted = cryptPassword(clear, algo);
    return (crypted.compare(cryptedBase64) == 0);
}
Пример #2
0
/** Checks equality between a clear password \e clear and
 * a encrypted password (in base64 encoding) \e cryptedBase64.
 * The encrypted password must have been created using the
 * cryptPassword().
 */
bool PasswordCrypter::checkPassword(const QString &clear, const QString &cryptedBase64)
{
    if (DebugCheckPassword)
        WARN_FUNC;
    // Get the prefixed algorithm
    Algorithm algo = SHA1;
    if (cryptedBase64.contains(":")) {
        algo = extractHashAlgorithm(cryptedBase64);
    }
    QString crypted = cryptPassword(clear, algo);
    if (DebugCheckPassword) {
        qDebug() << QString("clear: %1; crypted: %2\nhash: %3; comparison: %4")
                    .arg(clear).arg(cryptedBase64).arg(algo).arg(crypted);
    }
    return (crypted.compare(cryptedBase64) == 0);
}
Пример #3
0
/**
 * Checks the prefix of the encrypted password using \e algo.
 */
bool PasswordCrypter::checkPrefix(const QString &cryptedBase64, Algorithm algo)
{
    if (algo == ERROR)
        return false;
    return (extractHashAlgorithm(cryptedBase64) == algo);
}