diff options
author | Paul Duncan <pabs@pablotron.org> | 2023-09-07 18:13:49 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2023-09-07 18:13:49 -0400 |
commit | 0cc177de30f8acca210042ac68c1450883ecd2e3 (patch) | |
tree | fd8e8e0dee29883a8da16c3a648de870444ea495 /README.md | |
parent | 4eebef1961a1c01890fe11dc5f1b9f3a1ea705e0 (diff) | |
download | sha3-5cadc475e8836899d41f88e5ca67eb20ce9b4c5b.tar.bz2 sha3-5cadc475e8836899d41f88e5ca67eb20ce9b4c5b.zip |
README.md: add "Examples" sectionv0.2
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -27,6 +27,34 @@ Use `make` to build a minimal test application, and `make test` to run the test suite. +## Examples + +```c +// sha3-256-example: print sha3-256 hash of data to standard output. +#include <stdint.h> +#include <stdio.h> +#include "hex.h" +#include "sha3.h" + +// test data +static const uint8_t DATA[] = "this is some test data"; + +int main() { + // hash data + uint8_t buf[32] = { 0 }; + sha3_256(DATA, sizeof(DATA), buf); + + // print result to stdout + printf("SHA3-256: "); + hex_write(stdout, buf, sizeof(buf)); + printf("\n"); + + return 0; +} +``` + +See the `examples/` directory for more examples. + ## References * [FIPS 202 - SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions][FIPS 202] |