mirror of
https://github.com/python/cpython
synced 2026-09-29 10:15:30 +03:00
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
This commit is contained in:
parent
e506437b52
commit
f5cff56a1b
16 changed files with 118 additions and 135 deletions
|
|
@ -201,13 +201,11 @@ EVP_hexdigest(EVPobject *self, PyObject *unused)
|
|||
|
||||
/* Make hex version of the digest */
|
||||
for(i=j=0; i<digest_size; i++) {
|
||||
char c;
|
||||
unsigned char c;
|
||||
c = (digest[i] >> 4) & 0xf;
|
||||
c = (c>9) ? c+'a'-10 : c + '0';
|
||||
hex_digest[j++] = c;
|
||||
hex_digest[j++] = Py_hexdigits[c];
|
||||
c = (digest[i] & 0xf);
|
||||
c = (c>9) ? c+'a'-10 : c + '0';
|
||||
hex_digest[j++] = c;
|
||||
hex_digest[j++] = Py_hexdigits[c];
|
||||
}
|
||||
retval = PyUnicode_FromStringAndSize(hex_digest, digest_size * 2);
|
||||
PyMem_Free(hex_digest);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue