• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Welcome to ``pyca/cryptography``
2================================
3
4``cryptography`` includes both high level recipes and low level interfaces to
5common cryptographic algorithms such as symmetric ciphers, message digests, and
6key 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
21If you are interested in learning more about the field of cryptography, we
22recommend `Crypto 101, by Laurens Van Houtven`_ and `The Cryptopals Crypto
23Challenges`_.
24
25Installation
26------------
27You can install ``cryptography`` with ``pip``:
28
29.. code-block:: console
30
31    $ pip install cryptography
32
33See :doc:`Installation <installation>` for more information.
34
35.. _cryptography-layout:
36
37
38Layout
39------
40
41``cryptography`` is broadly divided into two levels. One with safe
42cryptographic recipes that require little to no configuration choices. These
43are safe and easy to use and don't require developers to make many decisions.
44
45The other level is low-level cryptographic primitives. These are often
46dangerous and can be used incorrectly. They require making decisions and having
47an in-depth knowledge of the cryptographic concepts at work. Because of the
48potential danger in working at this level, this is referred to as the
49"hazardous materials" or "hazmat" layer. These live in the
50``cryptography.hazmat`` package, and their documentation will always contain an
51admonition at the top.
52
53We recommend using the recipes layer whenever possible, and falling back to the
54hazmat layer only when necessary.
55
56.. toctree::
57    :maxdepth: 2
58    :caption: The recipes layer
59
60    fernet
61    x509/index
62
63.. toctree::
64    :maxdepth: 2
65    :caption: The hazardous materials layer
66
67    hazmat/primitives/index
68    exceptions
69    random-numbers
70    hazmat/backends/index
71
72.. toctree::
73    :maxdepth: 2
74    :caption: The cryptography open source project
75
76    installation
77    changelog
78    faq
79    development/index
80    security
81    limitations
82    api-stability
83    doing-a-release
84    community
85    glossary
86
87
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
92    :doc:`get in touch </community>`.
93
94.. _`Crypto 101, by Laurens Van Houtven`: https://www.crypto101.io/
95.. _`The Cryptopals Crypto Challenges`: https://cryptopals.com/
96