Created
March 4, 2015 10:45
-
-
Save ennorehling/f15b1cfa45ec1acd2332 to your computer and use it in GitHub Desktop.
Hex encoding in C
This file contains 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
void hex_encode(unsigned char * in, size_t inlen, char * out) { | |
size_t i; | |
for (i=0;i!=inlen;++i, out+=2) { | |
sprintf(out, "%02x", in[i]); | |
} | |
} | |
char digest[16] = "some_random_data"; | |
char buffer[64]; | |
hex_encode(digest, sizeof(digest), buffer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment