blob: f917ab45876a5fc071e1c4729cb0a12072ad6a59 [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
David Reid1f3d7182013-10-22 16:55:18 -07004.. currentmodule:: cryptography.primitives.hashes
5
6.. class:: BaseHash(data=None)
Matthew Iversen505491b2013-10-19 15:56:17 +11007
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -05008 Abstract base class that implements a common interface for all hash
9 algorithms that follow here.
Matthew Iversen505491b2013-10-19 15:56:17 +110010
Alex Gaynorf3b06cd2013-10-21 21:49:50 -070011 If ``data`` is provided ``update(data)`` is called upon construction.
12
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -050013 .. method:: update(data)
Matthew Iversen505491b2013-10-19 15:56:17 +110014
Alex Gaynorddc62f02013-10-20 06:14:24 -070015 :param bytes data: The bytes you wish to hash.
Matthew Iversen505491b2013-10-19 15:56:17 +110016
17 .. method:: copy()
18
Paul Kehrer6b9ddeb2013-10-19 12:28:15 -050019 :return: a new instance of this object with a copied internal state.
Matthew Iversen505491b2013-10-19 15:56:17 +110020
21 .. method:: digest()
22
23 :return bytes: The message digest as bytes.
24
25 .. method:: hexdigest()
26
27 :return str: The message digest as hex.
28
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050029SHA-1
Matthew Iversen505491b2013-10-19 15:56:17 +110030~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050031
32.. attention::
33
34 NIST has deprecated SHA-1 in favor of the SHA-2 variants. New applications
35 are strongly suggested to use SHA-2 over SHA-1.
36
David Reid1f3d7182013-10-22 16:55:18 -070037.. class:: SHA1()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050038
39 SHA-1 is a cryptographic hash function standardized by NIST. It has a
40 160-bit message digest.
41
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050042SHA-2 Family
Matthew Iversen505491b2013-10-19 15:56:17 +110043~~~~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050044
David Reid1f3d7182013-10-22 16:55:18 -070045.. class:: SHA224()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050046
47 SHA-224 is a cryptographic hash function from the SHA-2 family and
48 standardized by NIST. It has a 224-bit message digest.
49
David Reid1f3d7182013-10-22 16:55:18 -070050.. class:: SHA256()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050051
52 SHA-256 is a cryptographic hash function from the SHA-2 family and
53 standardized by NIST. It has a 256-bit message digest.
54
David Reid1f3d7182013-10-22 16:55:18 -070055.. class:: SHA384()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050056
57 SHA-384 is a cryptographic hash function from the SHA-2 family and
58 standardized by NIST. It has a 384-bit message digest.
59
David Reid1f3d7182013-10-22 16:55:18 -070060.. class:: SHA512()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050061
62 SHA-512 is a cryptographic hash function from the SHA-2 family and
63 standardized by NIST. It has a 512-bit message digest.
64
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050065RIPEMD160
Matthew Iversen505491b2013-10-19 15:56:17 +110066~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050067
David Reid1f3d7182013-10-22 16:55:18 -070068.. class:: RIPEMD160()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050069
70 RIPEMD160 is a cryptographic hash function that is part of ISO/IEC
71 10118-3:2004. It has a 160-bit message digest.
72
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050073Whirlpool
Matthew Iversen505491b2013-10-19 15:56:17 +110074~~~~~~~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050075
David Reid1f3d7182013-10-22 16:55:18 -070076.. class:: Whirlpool()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050077
78 Whirlpool is a cryptographic hash function that is part of ISO/IEC
79 10118-3:2004. It has a 512-bit message digest.
80
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050081MD5
Matthew Iversen505491b2013-10-19 15:56:17 +110082~~~
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050083
84.. warning::
85
86 MD5 is a deprecated hash algorithm that has practical known collision
87 attacks. You are strongly discouraged from using it.
88
David Reid1f3d7182013-10-22 16:55:18 -070089.. class:: MD5()
Paul Kehrer36e7d0d2013-10-18 18:54:40 -050090
91 MD5 is a deprecated cryptographic hash function. It has a 160-bit message
92 digest and has practical known collision attacks.