You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mkp224o/base16_to.c

22 lines
391 B

#include <stddef.h>
#include <stdint.h>
#include "types.h"
#include "base16.h"
static const char base16t[16] = {
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'A', 'B',
'C', 'D', 'E', 'F',
};
char *base16_to(char *dst, const u8 *src, size_t slen)
{
for (size_t i = 0; i < slen; ++i) {
*dst++ = base16t[src[i] >> 4];
*dst++ = base16t[src[i] & 15];
}
*dst = 0;
return dst;
}