aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2023-09-07 18:13:49 -0400
committerPaul Duncan <pabs@pablotron.org>2023-09-07 18:13:49 -0400
commit0cc177de30f8acca210042ac68c1450883ecd2e3 (patch)
treefd8e8e0dee29883a8da16c3a648de870444ea495
parent4eebef1961a1c01890fe11dc5f1b9f3a1ea705e0 (diff)
downloadsha3-0cc177de30f8acca210042ac68c1450883ecd2e3.tar.bz2
sha3-0cc177de30f8acca210042ac68c1450883ecd2e3.zip
README.md: add "Examples" sectionv0.2
-rw-r--r--README.md28
1 files changed, 28 insertions, 0 deletions
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 <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]