An stb-header implementation of the SHA-256 algorithm in C.
- C 86.7%
- Shell 13.3%
| data | ||
| .gitignore | ||
| build.sh | ||
| main.c | ||
| ReadMe.md | ||
| sha256.h | ||
| UNLICENSE | ||
SHA-256 Header Only Implementation in C
An stb-header implementation of the SHA-256 algorithm in C.
Build
To compile the code:
./build.sh
The build script will run some tests to confirm the code is working correctly. A test result will only be reported if a test fails.
The build script also calculates the time taken to generate a hash of War and Peace using sha256sum, and compares this to the time taken by this tool. For example:
SHA256SUM: 6 ms
SHA256: 15 ms
This tool is slower as it favours readability over performance, and does not take advantage of hardware optimisations such as those provided by SIMD or Intel SHA extensions.
Run
To run against a test file (War and Peace):
./sha256 data/war.txt
This will generate a hash of:
307c58e08a25e81af5879475cd1a7b4d789176d9535a8b1361ba297e81fc445e