Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(69888)

Side by Side Diff: Doc/library/hashlib.rst

Issue 26798: add BLAKE2 to hashlib
Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/hashlib-blake2.rst ('k') | Lib/hashlib.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`hashlib` --- Secure hashes and message digests 1 :mod:`hashlib` --- Secure hashes and message digests
2 ==================================================== 2 ====================================================
3 3
4 .. module:: hashlib 4 .. module:: hashlib
5 :synopsis: Secure hash and message digest algorithms. 5 :synopsis: Secure hash and message digest algorithms.
6 6
7 .. moduleauthor:: Gregory P. Smith <greg@krypto.org> 7 .. moduleauthor:: Gregory P. Smith <greg@krypto.org>
8 .. sectionauthor:: Gregory P. Smith <greg@krypto.org> 8 .. sectionauthor:: Gregory P. Smith <greg@krypto.org>
9 9
10 **Source code:** :source:`Lib/hashlib.py` 10 **Source code:** :source:`Lib/hashlib.py`
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 .. note:: 59 .. note::
60 60
61 Feeding string objects into :meth:`update` is not supported, as hashes work 61 Feeding string objects into :meth:`update` is not supported, as hashes work
62 on bytes, not on characters. 62 on bytes, not on characters.
63 63
64 .. index:: single: OpenSSL; (use in module hashlib) 64 .. index:: single: OpenSSL; (use in module hashlib)
65 65
66 Constructors for hash algorithms that are always present in this module are 66 Constructors for hash algorithms that are always present in this module are
67 :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, 67 :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`,
68 and :func:`sha512`. :func:`md5` is normally available as well, though it 68 :func:`sha512`, :func:`blake2b`, and :func:`blake2s`.
69 :func:`md5` is normally available as well, though it
69 may be missing if you are using a rare "FIPS compliant" build of Python. 70 may be missing if you are using a rare "FIPS compliant" build of Python.
70 Additional algorithms may also be available depending upon the OpenSSL 71 Additional algorithms may also be available depending upon the OpenSSL
71 library that Python uses on your platform. 72 library that Python uses on your platform.
72 73
74 .. versionadded:: 3.6
75 :func:`blake2b` and :func:`blake2s` were added.
76
73 For example, to obtain the digest of the byte string ``b'Nobody inspects the 77 For example, to obtain the digest of the byte string ``b'Nobody inspects the
74 spammish repetition'``:: 78 spammish repetition'``::
75 79
76 >>> import hashlib 80 >>> import hashlib
77 >>> m = hashlib.sha256() 81 >>> m = hashlib.sha256()
78 >>> m.update(b"Nobody inspects") 82 >>> m.update(b"Nobody inspects")
79 >>> m.update(b" the spammish repetition") 83 >>> m.update(b" the spammish repetition")
80 >>> m.digest() 84 >>> m.digest()
81 b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf \x0c\x95\x0fK\x94\x06' 85 b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf \x0c\x95\x0fK\x94\x06'
82 >>> m.digest_size 86 >>> m.digest_size
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 >>> binascii.hexlify(dk) 221 >>> binascii.hexlify(dk)
218 b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5' 222 b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5'
219 223
220 .. versionadded:: 3.4 224 .. versionadded:: 3.4
221 225
222 .. note:: 226 .. note::
223 227
224 A fast implementation of *pbkdf2_hmac* is available with OpenSSL. The 228 A fast implementation of *pbkdf2_hmac* is available with OpenSSL. The
225 Python implementation uses an inline version of :mod:`hmac`. It is about 229 Python implementation uses an inline version of :mod:`hmac`. It is about
226 three times slower and doesn't release the GIL. 230 three times slower and doesn't release the GIL.
231
232 BLAKE2
233 ------
234
235 BLAKE2 takes additional arguments, see :ref:`hashlib-blake2`.
227 236
228 237
229 .. seealso:: 238 .. seealso::
230 239
231 Module :mod:`hmac` 240 Module :mod:`hmac`
232 A module to generate message authentication codes using hashes. 241 A module to generate message authentication codes using hashes.
233 242
234 Module :mod:`base64` 243 Module :mod:`base64`
235 Another way to encode binary hashes for non-binary environments. 244 Another way to encode binary hashes for non-binary environments.
245
246 See :ref:`hashlib-blake2`.
236 247
237 http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf 248 http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
238 The FIPS 180-2 publication on Secure Hash Algorithms. 249 The FIPS 180-2 publication on Secure Hash Algorithms.
239 250
240 https://en.wikipedia.org/wiki/Cryptographic_hash_function#Cryptographic_hash_ algorithms 251 https://en.wikipedia.org/wiki/Cryptographic_hash_function#Cryptographic_hash_ algorithms
241 Wikipedia article with information on which algorithms have known issues a nd 252 Wikipedia article with information on which algorithms have known issues a nd
242 what that means regarding their use. 253 what that means regarding their use.
243 254
244 https://www.ietf.org/rfc/rfc2898.txt 255 https://www.ietf.org/rfc/rfc2898.txt
245 PKCS #5: Password-Based Cryptography Specification Version 2.0 256 PKCS #5: Password-Based Cryptography Specification Version 2.0
OLDNEW
« no previous file with comments | « Doc/library/hashlib-blake2.rst ('k') | Lib/hashlib.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+