An implementation of the SHA256 Hashing Algorithm in C
SHA-2 (Secure Hash Algorithm 2) is a set of cryptographic hash functions designed by the United States National Security Agency (NSA).
The standard for the algorithm can be found here.
The only thing you need to compile and/or run the script is a copy of the C compiler.
- Windows -
www.mingw.org
- Linux -
sudo apt-get install build-essential
- Solus -
sudo eopkg install -c system.devel
- Compile -
gcc SHA256.c -o SHA256
- Execute -
./SHA256 testFile1.txt
The project was done under the guidance of video lectures uploaded by Ian McLoughlin.
During the implementation of the project, research about the algorthim and it's standards was undertaken to try and better understand the intricacies of the algorthim.
The script correctly calculates the correct hash, this can be seen here. To fix the problem of the algorthim giving an incorrect hash, I had to add a missing 2 to my K
constant variable and change some of the SIG functions.
Check correctHashes.txt for more info.
The correct hashes for the given strings are as follows
abc
=ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855
abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
=248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1