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 | |
Alex Gaynor | f3b06cd | 2013-10-21 21:49:50 -0700 | [diff] [blame] | 4 | .. class:: cryptography.primitives.hashes.BaseHash(data=None) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 5 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 6 | Abstract base class that implements a common interface for all hash |
| 7 | algorithms that follow here. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 8 | |
Alex Gaynor | f3b06cd | 2013-10-21 21:49:50 -0700 | [diff] [blame] | 9 | If ``data`` is provided ``update(data)`` is called upon construction. |
| 10 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 11 | .. method:: update(data) |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 12 | |
Alex Gaynor | ddc62f0 | 2013-10-20 06:14:24 -0700 | [diff] [blame] | 13 | :param bytes data: The bytes you wish to hash. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 14 | |
| 15 | .. method:: copy() |
| 16 | |
Paul Kehrer | 6b9ddeb | 2013-10-19 12:28:15 -0500 | [diff] [blame] | 17 | :return: a new instance of this object with a copied internal state. |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 18 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 27 | SHA-1 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 28 | ~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 29 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 40 | SHA-2 Family |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 41 | ~~~~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 42 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 48 | .. 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 53 | .. 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 58 | .. 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 63 | RIPEMD160 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 64 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 65 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 71 | Whirlpool |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 72 | ~~~~~~~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 73 | |
| 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 Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 79 | MD5 |
Matthew Iversen | 505491b | 2013-10-19 15:56:17 +1100 | [diff] [blame] | 80 | ~~~ |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 81 | |
| 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 | |
Paul Kehrer | 2b9b301 | 2013-10-22 17:09:38 -0500 | [diff] [blame^] | 89 | MD5 is a deprecated cryptographic hash function. It has a 128-bit message |
Paul Kehrer | 36e7d0d | 2013-10-18 18:54:40 -0500 | [diff] [blame] | 90 | digest and has practical known collision attacks. |