Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 1 | Message Digests |
Alex Gaynor | ddc62f0 | 2013-10-20 06:14:24 -0700 | [diff] [blame] | 2 | =============== |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 3 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 4 | .. currentmodule:: cryptography.primitives.hashes |
| 5 | |
| 6 | .. class:: BaseHash(data=None) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 7 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 8 | Abstract base class that implements a common interface for all hash |
| 9 | algorithms that follow here. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 10 | |
Alex Gaynor | f3b06cd | 2013-10-21 21:49:50 -0700 | [diff] [blame] | 11 | If ``data`` is provided ``update(data)`` is called upon construction. |
| 12 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 13 | .. method:: update(data) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 14 | |
Alex Gaynor | ddc62f0 | 2013-10-20 06:14:24 -0700 | [diff] [blame] | 15 | :param bytes data: The bytes you wish to hash. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 16 | |
| 17 | .. method:: copy() |
| 18 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 19 | :return: a new instance of this object with a copied internal state. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 20 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 29 | SHA-1 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 30 | ~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 31 | |
| 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 Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 37 | .. class:: SHA1() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 38 | |
| 39 | SHA-1 is a cryptographic hash function standardized by NIST. It has a |
| 40 | 160-bit message digest. |
| 41 | |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 42 | SHA-2 Family |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 43 | ~~~~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 44 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 45 | .. class:: SHA224() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 46 | |
| 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 Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 50 | .. class:: SHA256() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 51 | |
| 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 Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 55 | .. class:: SHA384() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 56 | |
| 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 Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 60 | .. class:: SHA512() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 61 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 65 | RIPEMD160 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 66 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 67 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 68 | .. class:: RIPEMD160() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 69 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 73 | Whirlpool |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 74 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 75 | |
David Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 76 | .. class:: Whirlpool() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 77 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 81 | MD5 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 82 | ~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 83 | |
| 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 Reid | 1f3d718 | 2013-10-22 16:55:18 -0700 | [diff] [blame^] | 89 | .. class:: MD5() |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 90 | |
| 91 | MD5 is a deprecated cryptographic hash function. It has a 160-bit message |
| 92 | digest and has practical known collision attacks. |