diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 02:00:42 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-24 02:00:42 +0200 |
| commit | c22fa15f5c44a43e291c15f737515e35fb9dc6ba (patch) | |
| tree | 9a9ba4a26d629ce097d21732c0ebc25551e99ea2 /ot_hex.h | |
| parent | 4b736de708fe5e0a0fc8b4d9e1af77d3f4c096c0 (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.h | 25 |
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. */ | ||
| 15 | char *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. */ | ||
| 20 | int hex_tohash(ot_hash hash, const char *src); | ||
| 21 | |||
| 22 | /* Non-zero if c is a hexadecimal digit, in either case. */ | ||
| 23 | int hex_isdigit(int c); | ||
| 24 | |||
| 25 | #endif | ||
