Paul Kehrer | 1adb9aa | 2017-05-23 23:39:07 -0700 | [diff] [blame] | 1 | Welcome to ``pyca/cryptography`` |
| 2 | ================================ |
Alex Gaynor | 1abfac7 | 2013-08-07 12:59:04 -0700 | [diff] [blame] | 3 | |
Paul Kehrer | 9bab8bd | 2017-05-24 18:15:37 -0700 | [diff] [blame] | 4 | ``cryptography`` includes both high level recipes and low level interfaces to |
| 5 | common cryptographic algorithms such as symmetric ciphers, message digests, and |
Paul Kehrer | 51ef0eb | 2017-05-23 16:50:59 -0700 | [diff] [blame] | 6 | key derivation functions. For example, to encrypt something with |
| 7 | ``cryptography``'s high level symmetric encryption recipe: |
| 8 | |
| 9 | .. code-block:: pycon |
| 10 | |
| 11 | >>> from cryptography.fernet import Fernet |
| 12 | >>> # Put this somewhere safe! |
| 13 | >>> key = Fernet.generate_key() |
| 14 | >>> f = Fernet(key) |
| 15 | >>> token = f.encrypt(b"A really secret message. Not for prying eyes.") |
| 16 | >>> token |
| 17 | '...' |
| 18 | >>> f.decrypt(token) |
| 19 | 'A really secret message. Not for prying eyes.' |
| 20 | |
| 21 | If you are interested in learning more about the field of cryptography, we |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame] | 22 | recommend `Crypto 101, by Laurens Van Houtven`_ and `The Cryptopals Crypto |
| 23 | Challenges`_. |
Alex Gaynor | 31df535 | 2013-12-12 18:03:26 -0800 | [diff] [blame] | 24 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 25 | Installation |
| 26 | ------------ |
| 27 | You can install ``cryptography`` with ``pip``: |
| 28 | |
| 29 | .. code-block:: console |
| 30 | |
| 31 | $ pip install cryptography |
| 32 | |
Paul Kehrer | f3b57e3 | 2014-01-29 14:45:10 -0600 | [diff] [blame] | 33 | See :doc:`Installation <installation>` for more information. |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 34 | |
Alex Gaynor | 59a6bc6 | 2014-02-18 18:13:48 -0800 | [diff] [blame] | 35 | .. _cryptography-layout: |
| 36 | |
Paul Kehrer | 51ef0eb | 2017-05-23 16:50:59 -0700 | [diff] [blame] | 37 | |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 38 | Layout |
| 39 | ------ |
Alex Gaynor | 9f3468d | 2013-08-11 08:17:48 -0400 | [diff] [blame] | 40 | |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 41 | ``cryptography`` is broadly divided into two levels. One with safe |
Paul Kehrer | ece3af1 | 2017-05-29 23:03:10 -0500 | [diff] [blame] | 42 | cryptographic recipes that require little to no configuration choices. These |
| 43 | are safe and easy to use and don't require developers to make many decisions. |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 44 | |
| 45 | The other level is low-level cryptographic primitives. These are often |
| 46 | dangerous and can be used incorrectly. They require making decisions and having |
| 47 | an in-depth knowledge of the cryptographic concepts at work. Because of the |
Alex Gaynor | df8bfea | 2013-12-16 10:17:48 -0800 | [diff] [blame] | 48 | potential danger in working at this level, this is referred to as the |
Alex Gaynor | 77762bc | 2014-01-01 07:53:48 -0800 | [diff] [blame] | 49 | "hazardous materials" or "hazmat" layer. These live in the |
Alex Gaynor | d8614a2 | 2014-01-01 08:22:40 -0800 | [diff] [blame] | 50 | ``cryptography.hazmat`` package, and their documentation will always contain an |
Alex Gaynor | 77762bc | 2014-01-01 07:53:48 -0800 | [diff] [blame] | 51 | admonition at the top. |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 52 | |
| 53 | We recommend using the recipes layer whenever possible, and falling back to the |
| 54 | hazmat layer only when necessary. |
| 55 | |
Alex Gaynor | c62e91f | 2013-08-06 19:25:52 -0700 | [diff] [blame] | 56 | .. toctree:: |
Alex Gaynor | 1abfac7 | 2013-08-07 12:59:04 -0700 | [diff] [blame] | 57 | :maxdepth: 2 |
anarcat | fd2b27a | 2017-03-20 18:03:12 -0400 | [diff] [blame] | 58 | :caption: The recipes layer |
Alex Gaynor | 1abfac7 | 2013-08-07 12:59:04 -0700 | [diff] [blame] | 59 | |
Alex Gaynor | 333fb10 | 2013-10-31 10:27:35 -0700 | [diff] [blame] | 60 | fernet |
Alex Gaynor | 4af5b37 | 2015-07-12 10:30:59 -0500 | [diff] [blame] | 61 | x509/index |
Donald Stufft | f04317a | 2013-10-27 16:44:30 -0400 | [diff] [blame] | 62 | |
Donald Stufft | f04317a | 2013-10-27 16:44:30 -0400 | [diff] [blame] | 63 | .. toctree:: |
| 64 | :maxdepth: 2 |
anarcat | fd2b27a | 2017-03-20 18:03:12 -0400 | [diff] [blame] | 65 | :caption: The hazardous materials layer |
Donald Stufft | f04317a | 2013-10-27 16:44:30 -0400 | [diff] [blame] | 66 | |
| 67 | hazmat/primitives/index |
Paul Kehrer | e10d0d6 | 2017-05-29 08:49:47 -0500 | [diff] [blame] | 68 | exceptions |
| 69 | random-numbers |
Alex Gaynor | f8796b1 | 2013-12-13 20:28:55 -0800 | [diff] [blame] | 70 | hazmat/backends/index |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 71 | |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 72 | .. toctree:: |
| 73 | :maxdepth: 2 |
anarcat | fd2b27a | 2017-03-20 18:03:12 -0400 | [diff] [blame] | 74 | :caption: The cryptography open source project |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 75 | |
skeuomorf | b0293bf | 2014-01-29 21:41:02 +0200 | [diff] [blame] | 76 | installation |
Paul Kehrer | e10d0d6 | 2017-05-29 08:49:47 -0500 | [diff] [blame] | 77 | changelog |
| 78 | faq |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 79 | development/index |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 80 | security |
Alex Stapleton | 68bba2d | 2014-03-22 23:03:15 +0000 | [diff] [blame] | 81 | limitations |
Alex Gaynor | 1a9bbf2 | 2013-12-24 10:59:50 -0800 | [diff] [blame] | 82 | api-stability |
Alex Gaynor | 89063f6 | 2014-01-06 15:52:38 -0800 | [diff] [blame] | 83 | doing-a-release |
Alex Gaynor | 7c06746 | 2013-12-16 10:11:00 -0800 | [diff] [blame] | 84 | community |
Paul Kehrer | e10d0d6 | 2017-05-29 08:49:47 -0500 | [diff] [blame] | 85 | glossary |
Alex Gaynor | a8fc6f3 | 2014-01-23 10:48:16 -0600 | [diff] [blame] | 86 | |
| 87 | |
Alex Gaynor | 92ddd76 | 2014-03-03 19:39:40 -0800 | [diff] [blame] | 88 | .. note:: |
| 89 | |
| 90 | ``cryptography`` has not been subjected to an external audit of its code or |
| 91 | documentation. If you're interested in discussing an audit please |
Alex Gaynor | 0df8c97 | 2014-03-03 19:43:50 -0800 | [diff] [blame] | 92 | :doc:`get in touch </community>`. |
Alex Gaynor | 92ddd76 | 2014-03-03 19:39:40 -0800 | [diff] [blame] | 93 | |
Alex Gaynor | 1bcad7b | 2014-04-02 14:46:56 -0700 | [diff] [blame] | 94 | .. _`Crypto 101, by Laurens Van Houtven`: https://www.crypto101.io/ |
Lucia Li | c6ba99d | 2021-11-08 22:06:11 +0800 | [diff] [blame] | 95 | .. _`The Cryptopals Crypto Challenges`: https://cryptopals.com/ |