@brief Converts a hash to a null-terminated string Externalizes an hash as a null-terminated string into the first argument. Does so without internal procedure calls. Side Effects: none. Reentrancy: n/a. Thread Safety: safe. Mem Management: stomps the passed dest char*. @return returns the passed destination string ptr. */ reentrant version */
| 71 | */ |
| 72 | /* reentrant version */ |
| 73 | static char * |
| 74 | ink_code_to_hex_str(char *dest, uint8_t const *hash) |
| 75 | { |
| 76 | int i; |
| 77 | char *d; |
| 78 | |
| 79 | static char hex_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; |
| 80 | |
| 81 | d = dest; |
| 82 | for (i = 0; i < CRYPTO_HASH_SIZE; i += 4) { |
| 83 | *(d + 0) = hex_digits[hash[i + 0] >> 4]; |
| 84 | *(d + 1) = hex_digits[hash[i + 0] & 15]; |
| 85 | *(d + 2) = hex_digits[hash[i + 1] >> 4]; |
| 86 | *(d + 3) = hex_digits[hash[i + 1] & 15]; |
| 87 | *(d + 4) = hex_digits[hash[i + 2] >> 4]; |
| 88 | *(d + 5) = hex_digits[hash[i + 2] & 15]; |
| 89 | *(d + 6) = hex_digits[hash[i + 3] >> 4]; |
| 90 | *(d + 7) = hex_digits[hash[i + 3] & 15]; |
| 91 | d += 8; |
| 92 | } |
| 93 | *d = '\0'; |
| 94 | return (dest); |
| 95 | } |
| 96 | |
| 97 | char * |
| 98 | CryptoHash::toHexStr(char buffer[(CRYPTO_HASH_SIZE * 2) + 1]) const |