add hex_decode

This commit is contained in:
2024-03-28 18:30:27 -07:00
parent 360fb91e06
commit cf6d3ce892
4 changed files with 58 additions and 5 deletions

View File

@ -311,7 +311,7 @@ void test_string() {
void test_crypto() {
char *in = "BUTT";
char *s = b64_encode(in, strlen(in));
unsigned char *s = b64_encode(in, strlen(in));
assert(strcmp(s, "QlVUVA==") == 0);
free(s);
@ -326,6 +326,15 @@ void test_crypto() {
assert(strcmp(s, "a longer base64 test, apparently") == 0);
assert(strlen(s) == s_sz);
free(s);
s = hex_decode("DEADBEEF", &s_sz);
unsigned char h[4] = {
0xDE, 0xAD, 0xBE, 0xEF
};
for (size_t i = 0; i < 4; ++i) {
assert(s[i] == h[i]);
}
free(s);
}
#if defined(__APPLE__) || defined(__MACH__)