mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue 18240: The HMAC module is no longer restricted to bytes and accepts
any bytes-like object, e.g. memoryview. Original patch by Jonas Borgström.
This commit is contained in:
parent
ec4bdac8dd
commit
04926aeb2f
5 changed files with 33 additions and 11 deletions
|
@ -253,6 +253,20 @@ class ConstructorTestCase(unittest.TestCase):
|
|||
except:
|
||||
self.fail("Constructor call with text argument raised exception.")
|
||||
|
||||
def test_with_bytearray(self):
|
||||
try:
|
||||
h = hmac.HMAC(bytearray(b"key"), bytearray(b"hash this!"))
|
||||
self.assertEqual(h.hexdigest(), '34325b639da4cfd95735b381e28cb864')
|
||||
except:
|
||||
self.fail("Constructor call with bytearray arguments raised exception.")
|
||||
|
||||
def test_with_memoryview_msg(self):
|
||||
try:
|
||||
h = hmac.HMAC(b"key", memoryview(b"hash this!"))
|
||||
self.assertEqual(h.hexdigest(), '34325b639da4cfd95735b381e28cb864')
|
||||
except:
|
||||
self.fail("Constructor call with memoryview msg raised exception.")
|
||||
|
||||
def test_withmodule(self):
|
||||
# Constructor call with text and digest module.
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue