summaryrefslogtreecommitdiff
path: root/ot_hex.h
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:00:42 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:00:42 +0200
commitc22fa15f5c44a43e291c15f737515e35fb9dc6ba (patch)
tree9a9ba4a26d629ce097d21732c0ebc25551e99ea2 /ot_hex.h
parent4b736de708fe5e0a0fc8b4d9e1af77d3f4c096c0 (diff)
Move all code converting between binary and hex representation to its own unit
Diffstat (limited to 'ot_hex.h')
-rw-r--r--ot_hex.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/ot_hex.h b/ot_hex.h
new file mode 100644
index 0000000..cb2e86f
--- /dev/null
+++ b/ot_hex.h
@@ -0,0 +1,25 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
3
4 $id$ */
5
6#ifndef OT_HEX_H__
7#define OT_HEX_H__
8
9#include <stdint.h>
10
11#include "trackerlogic.h"
12
13/* Write hash as forty upper case hex digits followed by a terminating zero.
14 dest must have room for forty one bytes. Returns dest. */
15char *hex_fromhash(char *dest, const uint8_t *hash);
16
17/* Read forty hex digits from src into hash. Returns non-zero on success.
18 On failure hash is left untouched and no byte of src beyond the offending
19 character is read, so src need not be forty characters long. */
20int hex_tohash(ot_hash hash, const char *src);
21
22/* Non-zero if c is a hexadecimal digit, in either case. */
23int hex_isdigit(int c);
24
25#endif