aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives/symmetric-encryption.rst
diff options
context:
space:
mode:
authorGregory Haynes <greg@greghaynes.net>2015-01-03 09:17:41 -0800
committerGregory Haynes <greg@greghaynes.net>2015-01-03 09:17:41 -0800
commite261d94c914b02ba132b13ff6c0613d026c630bc (patch)
treec480f2e8b807dcd19243e8d834ec107a53e2757d /docs/hazmat/primitives/symmetric-encryption.rst
parent0f986114004a04cab8fea477e0eace29adab9531 (diff)
downloadcryptography-e261d94c914b02ba132b13ff6c0613d026c630bc.tar.gz
cryptography-e261d94c914b02ba132b13ff6c0613d026c630bc.tar.bz2
cryptography-e261d94c914b02ba132b13ff6c0613d026c630bc.zip
Assign iv to var and remove testsetup block
Diffstat (limited to 'docs/hazmat/primitives/symmetric-encryption.rst')
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst11
1 files changed, 3 insertions, 8 deletions
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 83230287..d532ad1b 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -6,12 +6,6 @@ Symmetric encryption
.. currentmodule:: cryptography.hazmat.primitives.ciphers
-.. testsetup::
-
- import binascii
- key = binascii.unhexlify(b"0" * 32)
- iv = binascii.unhexlify(b"0" * 32)
-
Symmetric encryption is a way to `encrypt`_ or hide the contents of material
where the sender and receiver both use the same secret key. Note that symmetric
@@ -39,8 +33,9 @@ in an "encrypt-then-MAC" formulation as `described by Colin Percival`_.
>>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
>>> from cryptography.hazmat.backends import default_backend
>>> backend = default_backend()
- >>> key = os.urandom(24)
- >>> cipher = Cipher(algorithms.AES(key), modes.CBC(os.urandom(16)), backend=backend)
+ >>> key = os.urandom(32)
+ >>> iv = os.urandom(16)
+ >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
>>> encryptor = cipher.encryptor()
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
>>> decryptor = cipher.decryptor()