File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ different scenarios.
59
59
scenarios/scientific
60
60
scenarios/imaging
61
61
scenarios/xml
62
+ scenarios/crypto
62
63
63
64
64
65
Shipping Great Code
Original file line number Diff line number Diff line change
1
+ Cryptography
2
+ ============
3
+
4
+ Cryptography
5
+ ------------
6
+
7
+ `Cryptography <https://cryptography.io/en/latest/ >`_ is an actively developed
8
+ library that provides cryptographic recipes and primitives. It supports
9
+ Python 2.6-2.7, Python 3.2+ and PyPy.
10
+
11
+
12
+ Cryptography is divided into two layers of recipes and hazardous materials (hazmat).
13
+ The recipes layer provides simple API for proper symmetric encryption and the
14
+ hazmat layer provides low-level cryptographic primitives.
15
+
16
+
17
+
18
+ Installation
19
+ ~~~~~~~~~~~~
20
+
21
+ .. code-block :: console
22
+
23
+ $ pip install cryptography
24
+
25
+ Example
26
+ ~~~~~~~
27
+
28
+ Example code using high level symmetric encryption recipe:
29
+
30
+ .. code-block :: python
31
+
32
+ from cryptography.fernet import Fernet
33
+ key = Fernet.generate_key()
34
+ cipher_suite = Fernet(key)
35
+ cipher_text = cipher_suite.encrypt(b " A really secret message. Not for prying eyes." )
36
+ plain_text = cipher_suite.decrypt(cipher_text)
37
+
38
+
39
+
40
+
41
+ PyCrypto
42
+ --------
43
+
44
+ `PyCrypto <https://www.dlitz.net/software/pycrypto/ >`_ is another library,
45
+ which provides secure hash functions and various encryption algorithms. It
46
+ supports Python version 2.1 through 3.3.
47
+
48
+ Installation
49
+ ~~~~~~~~~~~~
50
+
51
+ .. code-block :: console
52
+
53
+ $ pip install pycrypto
54
+
55
+ Example
56
+ ~~~~~~~
57
+
58
+ .. code-block :: python
59
+
60
+ from Crypto.Cipher import AES
61
+ # Encryption
62
+ encryption_suite = AES .new(' This is a key123' , AES .MODE_CBC , ' This is an IV456' )
63
+ cipher_text = encryption_suite.encrypt(" A really secret message. Not for prying eyes." )
64
+
65
+ # Decryption
66
+ decryption_suite = AES .new(' This is a key123' , AES .MODE_CBC , ' This is an IV456' )
67
+ plain_text = decryption_suite.decrypt(cipher_text)
You can’t perform that action at this time.
0 commit comments