add hex_to_str

This commit is contained in:
2024-03-29 07:18:01 -07:00
parent f60bea0fdd
commit 0408b8d499
4 changed files with 28 additions and 0 deletions

View File

@@ -243,3 +243,12 @@ const char *hex_encode(const unsigned char *hex, size_t sz) {
return s;
}
const char *hex_to_str(const unsigned char *hex, size_t sz) {
char *s = malloc(sizeof(char) * (sz + 1));
for (size_t i = 0; i < sz; ++i) {
s[i] = (char)hex[i];
}
s[sz] = '\0';
return s;
}