Skip to content

Instantly share code, notes, and snippets.

@bytepicker
Created December 20, 2017 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytepicker/c6b510e754884a35a08d408312d6256e to your computer and use it in GitHub Desktop.
Save bytepicker/c6b510e754884a35a08d408312d6256e to your computer and use it in GitHub Desktop.
unsigned char* intToHex(int n, unsigned char* bytes){
int size = sizeof(bytes);
for(int i=0; i<size+1; i++){
size--;
bytes[i] = ( n >> (size * 8)) & 0xFF;
}
bytes[sizeof(bytes)-1] = n & 0xFF; // last
return bytes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment