summaryrefslogtreecommitdiff
path: root/hex.h
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2023-09-06 23:23:08 -0400
committerPaul Duncan <pabs@pablotron.org>2023-09-06 23:23:08 -0400
commit7887a482dc7951a88fd0b2a4caa8988f0aef4340 (patch)
tree6f4b6a823da4447b8a6fa74343d4f31da720ea7b /hex.h
parent088e6c53453d672cc9110f8d0ec5355a1af6920f (diff)
downloadsha3-7887a482dc7951a88fd0b2a4caa8988f0aef4340.tar.bz2
sha3-7887a482dc7951a88fd0b2a4caa8988f0aef4340.zip
add hex.h, refactor main.c
Diffstat (limited to 'hex.h')
-rw-r--r--hex.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/hex.h b/hex.h
new file mode 100644
index 0000000..246aeed
--- /dev/null
+++ b/hex.h
@@ -0,0 +1,15 @@
+#ifndef HEX_H
+#define HEX_H
+
+#include <stdio.h> // fprintf()
+#include <stdint.h> // uint8_t
+
+// print hex-encoded buffer to given file handle.
+// (used by top-level main.c)
+static void hex_write(FILE *fh, const uint8_t * const buf, const size_t len) {
+ for (size_t i = 0; i < len; i++) {
+ fprintf(fh, "%02x", buf[i]);
+ }
+}
+
+#endif /* HEX_H */