Generating a MD5 Hash with Qt

馋奶兔 提交于 2019-12-20 09:27:09

问题


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?


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


来源:https://stackoverflow.com/questions/5495281/generating-a-md5-hash-with-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!