From 0cc177de30f8acca210042ac68c1450883ecd2e3 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 7 Sep 2023 18:13:49 -0400 Subject: README.md: add "Examples" section --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index a35cd04..fc08977 100644 --- a/README.md +++ b/README.md @@ -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 +#include +#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] -- cgit v1.2.3