diff options
author | Paul Duncan <pabs@pablotron.org> | 2023-09-06 23:23:08 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2023-09-06 23:23:08 -0400 |
commit | 7887a482dc7951a88fd0b2a4caa8988f0aef4340 (patch) | |
tree | 6f4b6a823da4447b8a6fa74343d4f31da720ea7b /hex.h | |
parent | 088e6c53453d672cc9110f8d0ec5355a1af6920f (diff) | |
download | sha3-7887a482dc7951a88fd0b2a4caa8988f0aef4340.tar.bz2 sha3-7887a482dc7951a88fd0b2a4caa8988f0aef4340.zip |
add hex.h, refactor main.c
Diffstat (limited to 'hex.h')
-rw-r--r-- | hex.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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 */ |