Reference Resource: FIPS PUB 180-4
Example hash values: Examples with Intermediate Values for SHA256 (This is very helpful for debugging)
curl is necessary for test build, or you can download doctest.h.
$ ./build.sh test
$ g++ --std=c++17 -g -Wall -Wextra -Wpedantic -Werror hash.h hash.cpp test.cpp -o test
$ ./test
If you want to open debug logs, you should define DEBUG_LOGS
macro such that
$ g++ --std=c++17 -g -Wall -Wextra -Wpedantic -Werror -DDEBUG_LOGS hash.h hash.cpp test.cpp -o test
$ ./build.sh app
$ g++ --std=c++17 -O3 -Wall -Wextra -Wpedantic -Werror -DNDEBUG hash.h hash.cpp sha256.cpp -o sha256
$ ./sha256 sha256.cpp
f843d418d1f3546ab63b6196c1a6225475a4c5c168e66bcdb0e90e322d7bf4fa sha256.cpp
$ cat sha256.cpp | ./sha256
f843d418d1f3546ab63b6196c1a6225475a4c5c168e66bcdb0e90e322d7bf4fa -