Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Created March 4, 2015 10:45
Show Gist options
  • Save ennorehling/f15b1cfa45ec1acd2332 to your computer and use it in GitHub Desktop.
Save ennorehling/f15b1cfa45ec1acd2332 to your computer and use it in GitHub Desktop.
Hex encoding in C
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