| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b3b4dbe commit 2f21eb3
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,8 +10,8 @@ | |||
| 10 | 10 | given hash function; initializing the hash | |
| 11 | 11 | using the given binary data. | |
| 12 | 12 | ||
| 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): | ||
| 15 | 15 | ||
| 16 | 16 | md5(), sha1(), sha224(), sha256(), sha384(), and sha512() | |
| 17 | 17 | ||
@@ -22,14 +22,13 @@ | |||
| 22 | 22 | sha384 and sha512 will be slow on 32 bit platforms. | |
| 23 | 23 | ||
| 24 | 24 | Hash 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 | ||
| 26 | 26 | are equivalent to a single call with the concatenation of all | |
| 27 | 27 | 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. | ||
| 33 | 32 | - copy(): Return a copy (clone) of the hash object. This can be used to | |
| 34 | 33 | efficiently compute the digests of strings that share a common | |
| 35 | 34 | initial substring. | |
@@ -54,11 +53,11 @@ | |||
| 54 | 53 | ||
| 55 | 54 | def __get_builtin_constructor(name): | |
| 56 | 55 | if name in ('SHA1', 'sha1'): | |
| 57 | - import _sha | ||
| 58 | - return _sha.new | ||
| 56 | + import _sha1 | ||
| 57 | + return _sha1.sha1 | ||
| 59 | 58 | elif name in ('MD5', 'md5'): | |
| 60 | 59 | import _md5 | |
| 61 | - return _md5.new | ||
| 60 | + return _md5.md5 | ||
| 62 | 61 | elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'): | |
| 63 | 62 | import _sha256 | |
| 64 | 63 | bs = name[3:] | |
@@ -78,7 +77,7 @@ def __get_builtin_constructor(name): | |||
| 78 | 77 | ||
| 79 | 78 | ||
| 80 | 79 | def __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; | ||
| 82 | 81 | optionally initialized with data (which must be bytes). | |
| 83 | 82 | """ | |
| 84 | 83 | return __get_builtin_constructor(name)(data) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments