1010 given hash function; initializing the hash
1111 using the given binary data.
1212
13- Named constructor functions are also available, these are much faster
14- than using new():
13+ Named constructor functions are also available, these are faster
14+ than using new(name ):
1515
1616md5(), sha1(), sha224(), sha256(), sha384(), and sha512()
1717
2222sha384 and sha512 will be slow on 32 bit platforms.
2323
2424Hash objects have these methods:
25- - update(arg): Update the hash object with the string arg. Repeated calls
25+ - update(arg): Update the hash object with the bytes in arg. Repeated calls
2626 are equivalent to a single call with the concatenation of all
2727 the arguments.
28- - digest(): Return the digest of the strings passed to the update() method
29- so far. This may contain non-ASCII characters, including
30- NUL bytes.
31- - hexdigest(): Like digest() except the digest is returned as a string of
32- double length, containing only hexadecimal digits.
28+ - digest(): Return the digest of the bytes passed to the update() method
29+ so far.
30+ - hexdigest(): Like digest() except the digest is returned as a unicode
31+ object of double length, containing only hexadecimal digits.
3332 - copy(): Return a copy (clone) of the hash object. This can be used to
3433 efficiently compute the digests of strings that share a common
3534 initial substring.
5453
5554def __get_builtin_constructor (name ):
5655 if name in ('SHA1' , 'sha1' ):
57- import _sha
58- return _sha . new
56+ import _sha1
57+ return _sha1 . sha1
5958 elif name in ('MD5' , 'md5' ):
6059 import _md5
61- return _md5 .new
60+ return _md5 .md5
6261 elif name in ('SHA256' , 'sha256' , 'SHA224' , 'sha224' ):
6362 import _sha256
6463 bs = name [3 :]
@@ -78,7 +77,7 @@ def __get_builtin_constructor(name):
7877
7978
8079def __py_new (name , data = b'' ):
81- """new(name, data='') - Return a new hashing object using the named algorithm;
80+ """new(name, data=b '') - Return a new hashing object using the named algorithm;
8281 optionally initialized with data (which must be bytes).
8382 """
8483 return __get_builtin_constructor (name )(data )
0 commit comments