多看看Qt core模塊會發現不少驚喜呀,裏面包含的類不少涉及到不少方面的功能實現html
先附上全部core類:Qt Core,再直接給出QCryptographicHash的幫助:QCryptographicHash算法
此類用於提供密碼散列,哈希值。能夠生成二進制或文本形式的hash值,並支持多種算法,算法能夠由QCryptographicHash::Algorithm選擇app
Constant | Value | Description |
---|---|---|
QCryptographicHash::Md4 |
0 |
Generate an MD4 hash sum |
QCryptographicHash::Md5 |
1 |
Generate an MD5 hash sum |
QCryptographicHash::Sha1 |
2 |
Generate an SHA-1 hash sum |
QCryptographicHash::Sha224 |
3 |
Generate an SHA-224 hash sum (SHA-2). Introduced in Qt 5.0 |
QCryptographicHash::Sha256 |
4 |
Generate an SHA-256 hash sum (SHA-2). Introduced in Qt 5.0 |
QCryptographicHash::Sha384 |
5 |
Generate an SHA-384 hash sum (SHA-2). Introduced in Qt 5.0 |
QCryptographicHash::Sha512 |
6 |
Generate an SHA-512 hash sum (SHA-2). Introduced in Qt 5.0 |
QCryptographicHash::Sha3_224 |
RealSha3_224 |
Generate an SHA3-224 hash sum. Introduced in Qt 5.1 |
QCryptographicHash::Sha3_256 |
RealSha3_256 |
Generate an SHA3-256 hash sum. Introduced in Qt 5.1 |
QCryptographicHash::Sha3_384 |
RealSha3_384 |
Generate an SHA3-384 hash sum. Introduced in Qt 5.1 |
QCryptographicHash::Sha3_512 |
RealSha3_512 |
Generate an SHA3-512 hash sum. Introduced in Qt 5.1 |
QCryptographicHash::Keccak_224 |
7 |
Generate a Keccak-224 hash sum. Introduced in Qt 5.9.2 |
QCryptographicHash::Keccak_256 |
8 |
Generate a Keccak-256 hash sum. Introduced in Qt 5.9.2 |
QCryptographicHash::Keccak_384 |
9 |
Generate a Keccak-384 hash sum. Introduced in Qt 5.9.2 |
QCryptographicHash::Keccak_512 |
10 |
Generate a Keccak-512 hash sum. Introduced in Qt 5.9.2 |
能夠實例化此類,構造時須要提供算法類型,而後經過addData須要計算hash的數據,最後經過result獲取結果,能夠利用reset清空數據但不能修改算法。post
還給了一個方便易用的靜態方法,直接提供算法類型及數據內容便可。網站
結果spa
其中test計算md5的結果是098f6bcd4621d373cade4e832627b4f6 能夠在相關網站反查結果:http://www.cmd5.com/,能夠證實計算正確。code