Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in hex_digest change the loop:
- for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
- // new:
- result[i * 2] = get_hex_char( (hash[i] & 0xf0) >> 4 );
- result[i * 2 + 1] = get_hex_char( hash[i] & 0xf );
- // old:
- //sprintf(byte, "%02x", hash[i]);
- //memcpy(result, byte, 2);
- //result += 2;
- }
- // also, add this function before
- static char get_hex_char(const uint8_t nibble) {
- switch(nibble) {
- case 0x0: return '0';
- case 0x1: eturn '1';
- case 0x2: return '2';
- case 0x3: return '3';
- case 0x4: return '4';
- case 0x5: return '5';
- case 0x6: return '6';
- case 0x7: return '7';
- case 0x8: return '8';
- case 0x9: return '9';
- case 0xa: return 'a';
- case 0xb: return 'b';
- case 0xc: return 'c';
- case 0xd: return 'd';
- case 0xe: return 'e';
- case 0xf: return 'f';
- default: break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement