diff options
| author | Gregory P. Smith <greg@krypto.org> | 2015-04-25 23:42:38 +0000 |
|---|---|---|
| committer | Gregory P. Smith <greg@krypto.org> | 2015-04-25 23:42:38 +0000 |
| commit | 4dff6f6fa6bfdc14c570d0c6a63021640203e1a6 (patch) | |
| tree | 0748440dd4b6782350481e768aa3ec56b48426e3 /Modules/md5module.c | |
| parent | 8cb6569fe14ba8e57ab1a2bea68594747852a9d1 (diff) | |
| download | cpython-git-4dff6f6fa6bfdc14c570d0c6a63021640203e1a6.tar.gz | |
Issue9951: update _hashopenssl and md5module to use _Py_strhex().
Also update _posixsubprocess to use Py_hexdigits instead of its own constant.
Diffstat (limited to 'Modules/md5module.c')
| -rw-r--r-- | Modules/md5module.c | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/Modules/md5module.c b/Modules/md5module.c index 00ee6c3379..a9ebc8cc51 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -18,6 +18,7 @@ #include "Python.h" #include "hashlib.h" +#include "pystrhex.h" /*[clinic input] module _md5 @@ -387,32 +388,12 @@ MD5Type_hexdigest_impl(MD5object *self) { unsigned char digest[MD5_DIGESTSIZE]; struct md5_state temp; - PyObject *retval; - Py_UCS1 *hex_digest; - int i, j; /* Get the raw (binary) digest value */ temp = self->hash_state; md5_done(&temp, digest); - /* Create a new string */ - retval = PyUnicode_New(MD5_DIGESTSIZE * 2, 127); - if (!retval) - return NULL; - hex_digest = PyUnicode_1BYTE_DATA(retval); - - /* Make hex version of the digest */ - for(i=j=0; i<MD5_DIGESTSIZE; i++) { - unsigned char c; - c = (digest[i] >> 4) & 0xf; - hex_digest[j++] = Py_hexdigits[c]; - c = (digest[i] & 0xf); - hex_digest[j++] = Py_hexdigits[c]; - } -#ifdef Py_DEBUG - assert(_PyUnicode_CheckConsistency(retval, 1)); -#endif - return retval; + return _Py_strhex((const char*)digest, MD5_DIGESTSIZE); } /*[clinic input] |
