MCPcopy Create free account
hub / github.com/apache/trafficserver / ink_code_to_hex_str

Function ink_code_to_hex_str

src/tscore/CryptoHash.cc:73–95  ·  view source on GitHub ↗

@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 */

Source from the content-addressed store, hash-verified

71*/
72/* reentrant version */
73static char *
74ink_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
97char *
98CryptoHash::toHexStr(char buffer[(CRYPTO_HASH_SIZE * 2) + 1]) const

Callers 1

toHexStrMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected