Created
January 8, 2019 07:43
-
-
Save alepez/04c6ae3ab44dfa9c62a0df905deb733e to your computer and use it in GitHub Desktop.
encodeBase16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void encodeBase16(char* const dst, const void* const src, const unsigned size) { | |
static const uint8_t table[] = "0123456789ABCDEF"; | |
char* d = dst; | |
const uint8_t* s = static_cast<const uint8_t*>(src); | |
const uint8_t* const sEnd = s + size; | |
while (s < sEnd) { | |
const uint8_t c = *s; | |
*d = table[c >> 4]; | |
++d; | |
*d = table[c & 0xf]; | |
++s; | |
++d; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment