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:
QString s = "hello world"; QByteArray hash = QCryptographicHash::hash(s.toLocal8bit(), QCryptographicHash::Md5);
You can check the documentation of QCryptographicHash class take a look here.
Comments are closed.