diff options
author | Gregory P. Smith <greg@krypto.org> | 2016-06-11 17:56:12 -0700 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2016-06-11 17:56:12 -0700 |
commit | 95aea0790fc42edd84e81d6b581f6c521fd4fe77 (patch) | |
tree | e5d0091f2976e860db295594757ffe3581cc5799 /Doc/library/hashlib.rst | |
parent | 5486e94c1ad7342d7a892631cc8e7ff33a022ae8 (diff) | |
download | cpython-95aea0790fc42edd84e81d6b581f6c521fd4fe77.tar.gz |
issue15468 - use sha256 instead of md5 or sha1 in the examples.
document that md5 may be missing in the rare case someone is using a
"FIPS compliant" build. I've only ever heard of Redhat creating one
of those - CPython itself offers no such build mode out of the box.
Diffstat (limited to 'Doc/library/hashlib.rst')
-rw-r--r-- | Doc/library/hashlib.rst | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Doc/library/hashlib.rst b/Doc/library/hashlib.rst index 30be3354af..085f99d0dc 100644 --- a/Doc/library/hashlib.rst +++ b/Doc/library/hashlib.rst @@ -39,8 +39,8 @@ Hash algorithms --------------- There is one constructor method named for each type of :dfn:`hash`. All return -a hash object with the same simple interface. For example: use :func:`sha1` to -create a SHA1 hash object. You can now feed this object with :term:`bytes-like +a hash object with the same simple interface. For example: use :func:`sha256` to +create a SHA-256 hash object. You can now feed this object with :term:`bytes-like objects <bytes-like object>` (normally :class:`bytes`) using the :meth:`update` method. At any point you can ask it for the :dfn:`digest` of the concatenation of the data fed to it so far using the :meth:`digest` or @@ -59,21 +59,23 @@ concatenation of the data fed to it so far using the :meth:`digest` or .. index:: single: OpenSSL; (use in module hashlib) Constructors for hash algorithms that are always present in this module are -:func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, -and :func:`sha512`. Additional algorithms may also be available depending upon -the OpenSSL library that Python uses on your platform. +:func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, +and :func:`sha512`. :func:`md5` is normally available as well, though it +may be missing if you are using a rare "FIPS compliant" build of Python. +Additional algorithms may also be available depending upon the OpenSSL +library that Python uses on your platform. For example, to obtain the digest of the byte string ``b'Nobody inspects the spammish repetition'``:: >>> import hashlib - >>> m = hashlib.md5() + >>> m = hashlib.sha256() >>> m.update(b"Nobody inspects") >>> m.update(b" the spammish repetition") >>> m.digest() - b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' + b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06' >>> m.digest_size - 16 + 32 >>> m.block_size 64 |