Last active
November 5, 2019 12:27
-
-
Save lemonlatte/684c6747a2f3b704c92da095eac550de to your computer and use it in GitHub Desktop.
encode hex
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
unsigned int encode_hex(char *out, size_t out_sz, uint8_t *in, size_t in_sz) { | |
if (in_sz*2 + 1>out_sz) { | |
return 0; | |
} | |
uint8_t i; | |
for (i = 0; i < in_sz; i++) { | |
snprintf(out+i*2, 3, "%02x", in[i]); | |
} | |
return in_sz*2+1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment