diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 40cc83a5fc5..6d5c5a48428 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -233,9 +233,9 @@ def check_blocksize_name(self, name, block_size=0, digest_size=0): self.assertEqual(m.block_size, block_size) self.assertEqual(m.digest_size, digest_size) self.assertEqual(len(m.digest()), digest_size) - self.assertEqual(m.name.lower(), name.lower()) + self.assertEqual(m.name, name) # split for sha3_512 / _sha3.sha3 object - self.assertIn(name.split("_")[0], repr(m).lower()) + self.assertIn(name.split("_")[0], repr(m)) def test_blocksize_name(self): self.check_blocksize_name('md5', 64, 16) diff --git a/Misc/NEWS b/Misc/NEWS index df728eaaa3c..229a25900b4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -28,6 +28,9 @@ Core and Builtins Library ------- +- Issue #18532: Change the builtin hash algorithms' names to lower case names + as promised by hashlib's documentation. + - Issue #18405: Improve the entropy of crypt.mksalt(). - Issue #12015: The tempfile module now uses a suffix of 8 random characters diff --git a/Modules/md5module.c b/Modules/md5module.c index 7dc38eaeedd..bb91b6c3698 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -439,7 +439,7 @@ MD5_get_block_size(PyObject *self, void *closure) static PyObject * MD5_get_name(PyObject *self, void *closure) { - return PyUnicode_FromStringAndSize("MD5", 3); + return PyUnicode_FromStringAndSize("md5", 3); } static PyObject * diff --git a/Modules/sha1module.c b/Modules/sha1module.c index e7c7ea671c4..403194c06be 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -411,7 +411,7 @@ SHA1_get_block_size(PyObject *self, void *closure) static PyObject * SHA1_get_name(PyObject *self, void *closure) { - return PyUnicode_FromStringAndSize("SHA1", 4); + return PyUnicode_FromStringAndSize("sha1", 4); } static PyObject * diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 767bfac602f..e60111ad02d 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -501,9 +501,9 @@ static PyObject * SHA256_get_name(PyObject *self, void *closure) { if (((SHAobject *)self)->digestsize == 32) - return PyUnicode_FromStringAndSize("SHA256", 6); + return PyUnicode_FromStringAndSize("sha256", 6); else - return PyUnicode_FromStringAndSize("SHA224", 6); + return PyUnicode_FromStringAndSize("sha224", 6); } static PyGetSetDef SHA_getseters[] = { diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 66c2c49c7f3..2841eabb2bf 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -567,9 +567,9 @@ static PyObject * SHA512_get_name(PyObject *self, void *closure) { if (((SHAobject *)self)->digestsize == 64) - return PyUnicode_FromStringAndSize("SHA512", 6); + return PyUnicode_FromStringAndSize("sha512", 6); else - return PyUnicode_FromStringAndSize("SHA384", 6); + return PyUnicode_FromStringAndSize("sha384", 6); } static PyGetSetDef SHA_getseters[] = {