mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-25 01:31:24 -04:00
parent
470a74ee24
commit
07efabed03
4 changed files with 27 additions and 6 deletions
|
@ -90,7 +90,7 @@ int OpenSSHKey::keyLength() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
const QString OpenSSHKey::fingerprint() const
|
||||
const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const
|
||||
{
|
||||
if (m_publicData.isEmpty()) {
|
||||
return {};
|
||||
|
@ -105,9 +105,20 @@ const QString OpenSSHKey::fingerprint() const
|
|||
stream.writeString(ba);
|
||||
}
|
||||
|
||||
QByteArray rawHash = QCryptographicHash::hash(publicKey, QCryptographicHash::Sha256);
|
||||
QByteArray rawHash = QCryptographicHash::hash(publicKey, algo);
|
||||
|
||||
return "SHA256:" + QString::fromLatin1(rawHash.toBase64(QByteArray::OmitTrailingEquals));
|
||||
if (algo == QCryptographicHash::Md5) {
|
||||
QString md5Hash = QString::fromLatin1(rawHash.toHex());
|
||||
QStringList md5HashParts;
|
||||
for (int i = 0; i < md5Hash.length(); i += 2) {
|
||||
md5HashParts.append(md5Hash.mid(i, 2));
|
||||
}
|
||||
return "MD5:" + md5HashParts.join(':');
|
||||
} else if (algo == QCryptographicHash::Sha256) {
|
||||
return "SHA256:" + QString::fromLatin1(rawHash.toBase64(QByteArray::OmitTrailingEquals));
|
||||
}
|
||||
|
||||
return "HASH:" + QString::fromLatin1(rawHash.toHex());
|
||||
}
|
||||
|
||||
const QString OpenSSHKey::comment() const
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
const QString cipherName() const;
|
||||
const QString type() const;
|
||||
int keyLength() const;
|
||||
const QString fingerprint() const;
|
||||
const QString fingerprint(QCryptographicHash::Algorithm algo = QCryptographicHash::Sha256) const;
|
||||
const QString comment() const;
|
||||
const QString publicKey() const;
|
||||
const QString errorString() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue