mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
[ sf.net patch # 1121611 ]
A new hashlib module to replace the md5 and sha modules. It adds support for additional secure hashes such as SHA-256 and SHA-512. The hashlib module uses OpenSSL for fast platform optimized implementations of algorithms when available. The old md5 and sha modules still exist as wrappers around hashlib to preserve backwards compatibility.
This commit is contained in:
parent
33a5f2af59
commit
f21a5f7739
21 changed files with 2589 additions and 53 deletions
|
@ -105,9 +105,10 @@ class SanityTestCase(unittest.TestCase):
|
|||
|
||||
def test_default_is_md5(self):
|
||||
# Testing if HMAC defaults to MD5 algorithm.
|
||||
import md5
|
||||
# NOTE: this whitebox test depends on the hmac class internals
|
||||
import hashlib
|
||||
h = hmac.HMAC("key")
|
||||
self.failUnless(h.digestmod == md5)
|
||||
self.failUnless(h.digest_cons == hashlib.md5)
|
||||
|
||||
def test_exercise_all_methods(self):
|
||||
# Exercising all methods once.
|
||||
|
@ -127,8 +128,8 @@ class CopyTestCase(unittest.TestCase):
|
|||
# Testing if attributes are of same type.
|
||||
h1 = hmac.HMAC("key")
|
||||
h2 = h1.copy()
|
||||
self.failUnless(h1.digestmod == h2.digestmod,
|
||||
"Modules don't match.")
|
||||
self.failUnless(h1.digest_cons == h2.digest_cons,
|
||||
"digest constructors don't match.")
|
||||
self.failUnless(type(h1.inner) == type(h2.inner),
|
||||
"Types of inner don't match.")
|
||||
self.failUnless(type(h1.outer) == type(h2.outer),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue