How to use cryptographic hash in Qt


Qt provides a simple but powerfull class to generate cryptographic hashes.

QCryptographicHash can be used to generate cryptographic hashes of binary or text data and supports MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 algorithms.

The most immediate way to generate a hash is using the static method QCryptographicHash::​hash(const QByteArray & data, Algorithm method).

For example, suppose to generate a md5 hash of “hello world” string:

You can check the documentation of QCryptographicHash class take a look here.