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 does 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?


Solution 1:

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())