10 void Hex::encodeInt(
const uint64_t decodedInt,
string& encodedString) {
12 char encodingCharSet[] =
"0123456789abcdef";
13 auto _decodedInt = decodedInt;
14 for (
auto i = 0; i < 32; i++) {
15 auto charIdx = _decodedInt & 15;
16 encodedString = encodingCharSet[charIdx] + encodedString;
18 if (_decodedInt == 0)
break;
23 char encodingCharSet[] =
"0123456789abcdef";
25 for (
auto i = 0; i < encodedString.length(); i++) {
27 char c = encodedString[encodedString.length() - i - 1];
28 char* codePtr = strchr(encodingCharSet, c);
29 if (codePtr == NULL) {
32 codeIdx = codePtr - encodingCharSet;
34 decodedInt+= codeIdx << (i * 4);
Integer to hex string conversion utility class.
static uint64_t decodeInt(const string &encodedString)
Decodes a hex string representation to an 64 bit unsigned integer.