Generating a MD5 Hash with Qt
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())
精彩评论