开发者

Generating a MD5 Hash with Qt

开发者 https://www.devze.com 2023-02-21 03:14 出处:网络
I am trying to generate an MD5 hash with Qt.The hash I generate needs to be compatible with other standard MD5 hashes generated with other languages such as PHP.

I am trying to generate an MD5 hash with Qt. The hash I generate needs to be compatible with other standard MD5 hashes generated with other languages such as PHP.

This code d开发者_如何学运维oes not give me the desired results:

QString encodedPass = QString(QCryptographicHash::hash(("myPassword"),QCryptographicHash::Md5));

The result is "Þ±SoHu÷Õ?!?¡¯×L" instead of "deb1536f480475f7d593219aa1afd74c". Can someone show me what I am doing wrong?


PHP gives it to you in hex, Qt in binary. Convert it to hex using QByteArray::toHex.

QString blah = QString(QCryptographicHash::hash(("myPassword"),QCryptographicHash::Md5).toHex())
0

精彩评论

暂无评论...
验证码 换一张
取 消