commit - b16893ba284e90739fc814673523878e8874dc0f
commit + 6853f3b18370bbdecf7f79c0afdfbd5bf065fb78
blob - 5906f438cafc3808c3de15f60410dc0e4c3361cd
blob + 714ead9c490fd270970c36841073e3b242f0a005
--- lib/hash.c
+++ lib/hash.c
static char *
digest_to_str(const uint8_t *digest, int len, char *buf)
{
+ const char hex[] = "0123456789abcdef";
char *p = buf;
- char hex[3];
int i;
for (i = 0; i < len; i++) {
- snprintf(hex, sizeof(hex), "%.2x", digest[i]);
- p[0] = hex[0];
- p[1] = hex[1];
- p += 2;
+ *p++ = hex[digest[i] >> 4];
+ *p++ = hex[digest[i] & 0xf];
}
- p[0] = '\0';
+ *p = '\0';
return buf;
}