A fast, lightweight hashing library written in C.
sshash is a custom hashing algorithm implementation that provides both 256-bit and 128-bit hash variants. It uses a sponge construction with a permutation-based design.
- 256-bit hashing: Using a 512-bit internal state
- 128-bit hashing: Using a 256-bit internal state
- Lightweight: Minimal dependencies, simple and fast
- Endianness support: Handles both big-endian and little-endian systems
uint64_t sshasha256(uint64_t state[8], uint64_t ctr, const void* data, size_t datalen);
void sshashs256(uint64_t state[8], uint64_t hash[4]);sshasha256: Absorbs data into the 512-bit state. Returns updated counter for chaining.sshashs256: Squeezes the state to produce a 256-bit hash.
uint32_t sshasha128(uint32_t state[8], uint32_t ctr, const void* data, size_t datalen);
void sshashs128(uint32_t state[8], uint32_t hash[4]);sshasha128: Absorbs data into the 256-bit state. Returns updated counter for chaining.sshashs128: Squeezes the state to produce a 128-bit hash.
Create output directories:
mkdir -p lib bin ctestsCompile the library:
gcc -Wall -Wextra -Wpedantic -Werror -O3 -I./include -c src/sshash.c -o lib/sshash.o
ar rcs lib/libsshash.a lib/sshash.o
rm lib/sshash.oBuild the CLI tool:
gcc -Wall -Wextra -Wpedantic -Werror -O3 -I./include -L./lib -s -o bin/sshash tools/sshash.c -lsshashBuild speed test:
gcc -Wall -Wextra -Wpedantic -Werror -O3 -I./include -L./lib -g -o ctests/speed tests/speed.c -lsshashBuild security test:
gcc -Wall -Wextra -Wpedantic -Werror -O3 -I./include -L./lib -g -o ctests/security tests/security.c -lsshashRun tests:
./ctests/test_speed
./ctests/test_securitysrc/- Source codeinclude/- Public headerslib/- Compiled librarytests/- Test suitectests/- Compiled testsbin/- Compiled binariestools/- Utility tools