QCryptographicHash Class Reference

The QCryptographicHash class provides a way to generate cryptographic hashes. More...

 #include <QCryptographicHash>

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.3.

Public Types

enum Algorithm { Md4, Md5, Sha1 }

Public Functions

QCryptographicHash ( Algorithm method )
~QCryptographicHash ()
void addData ( const char * data, int length )
void addData ( const QByteArray & data )
void reset ()
QByteArray result () const

Static Public Members

QByteArray hash ( const QByteArray & data, Algorithm method )

Detailed Description

The QCryptographicHash class provides a way to generate cryptographic hashes.

QCryptographicHash can be used to generate cryptographic hashes of binary or text data.

Currently MD4, MD5, and SHA-1 are supported.

Member Type Documentation

enum QCryptographicHash::Algorithm

ConstantValueDescription
QCryptographicHash::Md40Generate an MD4 hash sum
QCryptographicHash::Md51Generate an MD5 hash sum
QCryptographicHash::Sha12Generate an SHA1 hash sum

Member Function Documentation

QCryptographicHash::QCryptographicHash ( Algorithm method )

Constructs an object that can be used to create a cryptographic hash from data using method.

QCryptographicHash::~QCryptographicHash ()

Destroys the object.

void QCryptographicHash::addData ( const char * data, int length )

Adds the first length chars of data to the cryptographic hash.

void QCryptographicHash::addData ( const QByteArray & data )

This function overloads addData().

QByteArray QCryptographicHash::hash ( const QByteArray & data, Algorithm method ) [static]

Returns the hash of data using method.

void QCryptographicHash::reset ()

Resets the object.

QByteArray QCryptographicHash::result () const

Returns the final hash value.

See also QByteArray::toHex().

Notes provided by the Qt Community
Informative
  • 2

Votes: 1

Coverage: Qt library 4.7, 4.8

Picture of tucnak tucnak

Hobby Entomologist
2 notes

QCA

QCryptographicHash provides an implementation of some cryptographic hashes (MD4, MD5, SHA1).

If for some reason you need to use other hashing algorithms (SHA256, SHA512), or, in general, to encrypt and decrypt data (f.i. by using AES, Blowfish, etc.), you can use QCA (Qt Cryptography Architecture).

http://delta.affinix.com/qca/

[Revisions]