sha

Implementation of SHA 1, 256, 384, and 512

As a continuation of the previous entry about the implementation of SHA-1, I've now implemented the last three algorithms as well. These are SHA-256, SHA-384, and SHA-512. SHA-1 provided a 160-bit digest, SHA-256 provides a 256-bit digest, SHA-384 provides a 384-bit digest, and, believe it or not, SHA-512 provides a 512-bit digest. These algorithms are described in FIPS 180-2.

The usage is the same as for SHA-1, except for a little detail of specifying the exact algorithm to use:

>>> import sha

Implementation of the Secure Hash Algorithm (SHA) 1

As a bit of fun I implemented the Secure Hash Algorithm (SHA) 1 late last night. It was done using Python3 and accordingly to FIPS 180-1.

Below is shown how to use it:

>>> import sha1
>>> data = sha1.str2bin("All your base are belong to us!")
>>> sha1.digest(data)
'1110101011101101100000101101000101010000110001110110110010000011
 1101011101110100101001110011011101001110011110001100111000000111
 11010001110010001100100010100110'
>>> sha1.hex_digest(data)
Syndicate content