From f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 14 Oct 2011 02:13:11 +0200 Subject: Issue #13088: Add shared Py_hexdigits constant to format a number into base 16 --- Modules/sha512module.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Modules/sha512module.c') diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 417700073e..4f5a1139ee 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -526,13 +526,11 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused) /* Make hex version of the digest */ for (i=j=0; idigestsize; 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]; } return retval; } -- cgit v1.2.1