blob: d4dde04257ad5c47f97e5b854f33410fe327c8ab [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
Matthew Iversen505491b2013-10-19 15:56:17 +11004.. class:: cryptography.primitives.hashes.BaseHash
5
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
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -05009 .. method:: update(data)
Matthew Iversen505491b2013-10-19 15:56:17 +110010
Alex Gaynorddc62f02013-10-20 06:14:24 -070011 :param bytes data: The bytes you wish to hash.
Matthew Iversen505491b2013-10-19 15:56:17 +110012
13 .. method:: copy()
14
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -050015 :return: a new instance of this object with a copied internal state.
Matthew Iversen505491b2013-10-19 15:56:17 +110016
17 .. method:: digest()
18
19 :return bytes: The message digest as bytes.
20
21 .. method:: hexdigest()
22
23 :return str: The message digest as hex.
24
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050025SHA-1
Matthew Iversen505491b2013-10-19 15:56:17 +110026~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050027
28.. attention::
29
30 NIST has deprecated SHA-1 in favor of the SHA-2 variants. New applications
31 are strongly suggested to use SHA-2 over SHA-1.
32
33.. class:: cryptography.primitives.hashes.SHA1()
34
35 SHA-1 is a cryptographic hash function standardized by NIST. It has a
36 160-bit message digest.
37
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050038SHA-2 Family
Matthew Iversen505491b2013-10-19 15:56:17 +110039~~~~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050040
41.. class:: cryptography.primitives.hashes.SHA224()
42
43 SHA-224 is a cryptographic hash function from the SHA-2 family and
44 standardized by NIST. It has a 224-bit message digest.
45
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050046.. class:: cryptography.primitives.hashes.SHA256()
47
48 SHA-256 is a cryptographic hash function from the SHA-2 family and
49 standardized by NIST. It has a 256-bit message digest.
50
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050051.. class:: cryptography.primitives.hashes.SHA384()
52
53 SHA-384 is a cryptographic hash function from the SHA-2 family and
54 standardized by NIST. It has a 384-bit message digest.
55
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050056.. class:: cryptography.primitives.hashes.SHA512()
57
58 SHA-512 is a cryptographic hash function from the SHA-2 family and
59 standardized by NIST. It has a 512-bit message digest.
60
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050061RIPEMD160
Matthew Iversen505491b2013-10-19 15:56:17 +110062~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050063
64.. class:: cryptography.primitives.hashes.RIPEMD160()
65
66 RIPEMD160 is a cryptographic hash function that is part of ISO/IEC
67 10118-3:2004. It has a 160-bit message digest.
68
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050069Whirlpool
Matthew Iversen505491b2013-10-19 15:56:17 +110070~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050071
72.. class:: cryptography.primitives.hashes.Whirlpool()
73
74 Whirlpool is a cryptographic hash function that is part of ISO/IEC
75 10118-3:2004. It has a 512-bit message digest.
76
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050077MD5
Matthew Iversen505491b2013-10-19 15:56:17 +110078~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050079
80.. warning::
81
82 MD5 is a deprecated hash algorithm that has practical known collision
83 attacks. You are strongly discouraged from using it.
84
85.. class:: cryptography.primitives.hashes.MD5()
86
87 MD5 is a deprecated cryptographic hash function. It has a 160-bit message
88 digest and has practical known collision attacks.