From f1f183e634150cb78e2faf694dad70a57310df16 Mon Sep 17 00:00:00 2001 From: Amirali Sanatinia Date: Sun, 27 Jul 2014 21:23:20 -0400 Subject: [PATCH 1/3] add crypto --- docs/scenarios/crypto.rst | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 docs/scenarios/crypto.rst diff --git a/docs/scenarios/crypto.rst b/docs/scenarios/crypto.rst new file mode 100644 index 0000000..17e8609 --- /dev/null +++ b/docs/scenarios/crypto.rst @@ -0,0 +1,71 @@ +Cryptography +============ + +Cryptography +------------ + +`Cryptography `_ is an actively developed +library that provides cryptographic recipes and primitives. It supports +Python 2.6-2.7, Python 3.2+ and PyPy. + + +Cryptography is divided into two layers of recipes and hazardous materials (hazmat). +The recipes layer provides simple API for proper symmetric encryption and the +hazmat layer provides low-level cryptographic primitives. + + + +Installation +~~~~~~~~~~~~ + +.. code-block:: console + + $ pip install cryptography + +Example +~~~~~~~ + +Example code using high level symmetric encryption recipe: + +.. code-block:: python + + from cryptography.fernet import Fernet + key = Fernet.generate_key() + cipher_suite = Fernet(key) + cipher_text = cipher_suite.encrypt(b"A really secret message. Not for prying eyes.") + plain_text = cipher_suite.decrypt(cipher_text) + + + + +PyCrypto +-------- + +`PyCrypto `_ is another library, +which provides secure hash functions and various encryption algorithms. It +supports Python version 2.1 through 3.3. + +Installation +~~~~~~~~~~~~ + +.. code-block:: console + + $ pip install pycrypto + +Example +~~~~~~~ + +.. code-block:: python + + from Crypto.Cipher import AES + # Encryption + encryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') + cipher_text = encryption_suite.encrypt("A really secret message. Not for prying eyes.") + + # Decryption + decryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') + plain_text = decryption_suite.decrypt(cipher_text) + + + + From e5f978ac45a59b64f993b57e12d0521207fed468 Mon Sep 17 00:00:00 2001 From: Amirali Sanatinia Date: Sun, 27 Jul 2014 21:42:13 -0400 Subject: [PATCH 2/3] Remove extra whitespace --- docs/scenarios/crypto.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/scenarios/crypto.rst b/docs/scenarios/crypto.rst index 17e8609..15f3af7 100644 --- a/docs/scenarios/crypto.rst +++ b/docs/scenarios/crypto.rst @@ -65,7 +65,3 @@ Example # Decryption decryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456') plain_text = decryption_suite.decrypt(cipher_text) - - - - From a2f44b8dc5ec69f40298a4eaa1d969e63db0e0f7 Mon Sep 17 00:00:00 2001 From: Amirali Sanatinia Date: Sun, 27 Jul 2014 21:45:12 -0400 Subject: [PATCH 3/3] Add crpto below xml in scenarios --- docs/contents.rst.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/contents.rst.inc b/docs/contents.rst.inc index 7887307..8e8cd73 100644 --- a/docs/contents.rst.inc +++ b/docs/contents.rst.inc @@ -59,6 +59,7 @@ different scenarios. scenarios/scientific scenarios/imaging scenarios/xml + scenarios/crypto Shipping Great Code