:: printable version ::

SHA-1 hashing algorithm

::description ::changelog ::requirements ::features ::usage ::tech ::

Description

A small class implementing the SHA1 hashing algorithm.

SHA (Secure Hash Algorithm) is a cryptographically safe function developed by NIST and NSA in 1992. It fulfills all the requirements imposed for one-way hashing functions and it generates very different images for similar sequences. This code is based on the 100% free public domain implementation by Dominik Reichl.

NO WARRANTY is given for this code. Use it at your own risk. It should always compute correct SHA1 digests, but no security-related tests have been made.

Changelog

Requirements

Features

::top::

Usage example

Compute SHA1 hash for a file or byte array:

#include <QByteArray> #include "sha1hash.h" // ... // You better chose a different filename ;) QString filename("/dev/random"); QString s("Hello World!"); QByteArray buffer = s.toAscii(); QString digest1 = SHA1Hash::hashFile(filename); // Let's hash the world!! QString digest2 = SHA1Hash::hashData(buffer); // ...or just some bytes // ...

Everything is static, so you don't need to instantiate any class.

Technical details

Sensitive data

If you are handling sensitive data you may want to "clean" used variables before leaving the hashFile() method, so simply remove the comments at the end of the method.

:: index :: top ::