Make bin2hex() code consistent with hex2bin()
This commit is contained in:
parent
ae66518567
commit
788d8d0178
@ -108,14 +108,14 @@ sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
||||
while (i < bin_len) {
|
||||
c = bin[i] & 0xf;
|
||||
b = bin[i] >> 4;
|
||||
x = (unsigned char) (87 + c + (((c - 10) >> 31) & -39)) << 8 |
|
||||
(unsigned char) (87 + b + (((b - 10) >> 31) & -39));
|
||||
x = (unsigned char) (87U + c + (((c - 10U) >> 8) & ~38U)) << 8 |
|
||||
(unsigned char) (87U + b + (((b - 10U) >> 8) & ~38U));
|
||||
hex[i * 2U] = (char) x;
|
||||
x >>= 8;
|
||||
hex[i * 2U + 1U] = (char) x;
|
||||
i++;
|
||||
}
|
||||
hex[i * 2U] = 0;
|
||||
hex[i * 2U] = 0U;
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user