- for (i = 0; i < 20; i++)
- offset += sprintf(out + offset, "%02x", hash[i]);
+ for (i = 0; i < 20; i++) {
+ out[offset++] = hexdigits[hash[i] >> 4];
+ out[offset++] = hexdigits[hash[i] & 0x0f];
+ }
+
+ out[offset] = '\0';
+}
+
+static inline uint8_t nibble(char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+
+ /* Force lower case so we don't need to check
+ * for upper case characters.
+ */
+ c |= 32;
+
+ return c - 'a' + 10;