blob: aeb30f406d6d2092ef912fb34739370e3b86c742 [file] [log] [blame]
Paul Kehrer36e7d0d2013-10-18 18:54:40 -05001Message Digests
Alex Gaynorddc62f02013-10-20 06:14:24 -07002===============
Paul Kehrer36e7d0d2013-10-18 18:54:40 -05003
Alex Gaynorf3b06cd2013-10-21 21:49:50 -07004.. class:: cryptography.primitives.hashes.BaseHash(data=None)
Matthew Iversen505491b2013-10-19 15:56:17 +11005
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -05006 Abstract base class that implements a common interface for all hash
7 algorithms that follow here.
Matthew Iversen505491b2013-10-19 15:56:17 +11008
Alex Gaynorf3b06cd2013-10-21 21:49:50 -07009 If ``data`` is provided ``update(data)`` is called upon construction.
10
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -050011 .. method:: update(data)
Matthew Iversen505491b2013-10-19 15:56:17 +110012
Alex Gaynorddc62f02013-10-20 06:14:24 -070013 :param bytes data: The bytes you wish to hash.
Matthew Iversen505491b2013-10-19 15:56:17 +110014
15 .. method:: copy()
16
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -050017 :return: a new instance of this object with a copied internal state.
Matthew Iversen505491b2013-10-19 15:56:17 +110018
19 .. method:: digest()
20
21 :return bytes: The message digest as bytes.
22
23 .. method:: hexdigest()
24
25 :return str: The message digest as hex.
26
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050027SHA-1
Matthew Iversen505491b2013-10-19 15:56:17 +110028~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050029
30.. attention::
31
32 NIST has deprecated SHA-1 in favor of the SHA-2 variants. New applications
33 are strongly suggested to use SHA-2 over SHA-1.
34
35.. class:: cryptography.primitives.hashes.SHA1()
36
37 SHA-1 is a cryptographic hash function standardized by NIST. It has a
38 160-bit message digest.
39
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050040SHA-2 Family
Matthew Iversen505491b2013-10-19 15:56:17 +110041~~~~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050042
43.. class:: cryptography.primitives.hashes.SHA224()
44
45 SHA-224 is a cryptographic hash function from the SHA-2 family and
46 standardized by NIST. It has a 224-bit message digest.
47
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050048.. class:: cryptography.primitives.hashes.SHA256()
49
50 SHA-256 is a cryptographic hash function from the SHA-2 family and
51 standardized by NIST. It has a 256-bit message digest.
52
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050053.. class:: cryptography.primitives.hashes.SHA384()
54
55 SHA-384 is a cryptographic hash function from the SHA-2 family and
56 standardized by NIST. It has a 384-bit message digest.
57
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050058.. class:: cryptography.primitives.hashes.SHA512()
59
60 SHA-512 is a cryptographic hash function from the SHA-2 family and
61 standardized by NIST. It has a 512-bit message digest.
62
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050063RIPEMD160
Matthew Iversen505491b2013-10-19 15:56:17 +110064~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050065
66.. class:: cryptography.primitives.hashes.RIPEMD160()
67
68 RIPEMD160 is a cryptographic hash function that is part of ISO/IEC
69 10118-3:2004. It has a 160-bit message digest.
70
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050071Whirlpool
Matthew Iversen505491b2013-10-19 15:56:17 +110072~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050073
74.. class:: cryptography.primitives.hashes.Whirlpool()
75
76 Whirlpool is a cryptographic hash function that is part of ISO/IEC
77 10118-3:2004. It has a 512-bit message digest.
78
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050079MD5
Matthew Iversen505491b2013-10-19 15:56:17 +110080~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050081
82.. warning::
83
84 MD5 is a deprecated hash algorithm that has practical known collision
85 attacks. You are strongly discouraged from using it.
86
87.. class:: cryptography.primitives.hashes.MD5()
88
89 MD5 is a deprecated cryptographic hash function. It has a 160-bit message
90 digest and has practical known collision attacks.