Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.15.2
-
None
Description
QCryptographicHash::hash will return a QByteArray value. But when the value contains 0x00, the value is invalid because QByteArray::data will return data with ‘/0’ termination。And I can't get the complete value by someway at this time.
code(line196-214):
https://github.com/moonlight-stream/moonlight-qt/blob/master/app/backend/nvpairingmanager.cpp
the aesKey value is invalid sometimes because QCryptographicHash::hash return value contains 0x00.
PS:
It maybe need to change class QCryptographicHash member: d->result construction.
Use QByteArray::QByteArray(const char *data, int size = -1)
//C++ #include <QCoreApplication> #include <QCryptographicHash> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QByteArray b = QByteArray::fromHex("b8d626cbe3218160752f8be86bf570ec"); QString c = "1234"; QByteArray to_hash_data; to_hash_data = QByteArray().append(b).append(c.toLatin1()); qInfo() << to_hash_data.toHex(); QByteArray aesKey = QCryptographicHash::hash(to_hash_data, QCryptographicHash::Sha256).constData(); qInfo() << "aesKey data size:" << strlen(aesKey.data()); // output: aesKey data size:1 return a.exec(); }