aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-13 15:19:22 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-13 15:19:22 -0800
commitf56444df44faf8c030a82a042a198b6fa77caa72 (patch)
tree6b61ec7926efd38e61f617aeed13edf2a5a4758d /docs
parentdb042cdb07f08662531246b8ae58f437f2104ad3 (diff)
downloadcryptography-f56444df44faf8c030a82a042a198b6fa77caa72.tar.gz
cryptography-f56444df44faf8c030a82a042a198b6fa77caa72.tar.bz2
cryptography-f56444df44faf8c030a82a042a198b6fa77caa72.zip
Always show where a baackend comes form in the docs
Diffstat (limited to 'docs')
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst11
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 2f390175..ef6f0871 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -12,9 +12,6 @@ Symmetric Encryption
key = binascii.unhexlify(b"0" * 32)
iv = binascii.unhexlify(b"0" * 32)
- from cryptography.hazmat.bindings import default_backend
- backend = default_backend()
-
Symmetric encryption is a way to encrypt (hide the plaintext value) material
where the sender and receiver both use the same key. Note that symmetric
@@ -37,6 +34,8 @@ an "encrypt-then-MAC" formulation as `described by Colin Percival`_.
.. doctest::
>>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+ >>> from cryptography.hazmat.bindings import default_backend
+ >>> backend = default_backend()
>>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
>>> encryptor = cipher.encryptor()
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
@@ -230,8 +229,9 @@ Weak Ciphers
.. doctest::
>>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
+ >>> from cryptography.hazmat.bindings import default_backend
>>> algorithm = algorithms.ARC4(key)
- >>> cipher = Cipher(algorithm, mode=None, backend=backend)
+ >>> cipher = Cipher(algorithm, mode=None, backend=default_backend())
>>> encryptor = cipher.encryptor()
>>> ct = encryptor.update(b"a secret message")
>>> decryptor = cipher.decryptor()
@@ -356,7 +356,8 @@ Modes
.. doctest::
>>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
- >>> cipher = Cipher(algorithms.AES(key), modes.GCM(iv), backend)
+ >>> from cryptography.hazmat.bindings import default_backend
+ >>> cipher = Cipher(algorithms.AES(key), modes.GCM(iv), backend=default_backend())
>>> encryptor = cipher.encryptor()
>>> encryptor.authenticate_additional_data(b"authenticated but not encrypted payload")
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()