aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives/symmetric-encryption.rst
diff options
context:
space:
mode:
authorGregory Haynes <greg@greghaynes.net>2014-12-30 09:43:24 -0800
committerGregory Haynes <greg@greghaynes.net>2014-12-30 09:43:24 -0800
commit0f986114004a04cab8fea477e0eace29adab9531 (patch)
tree66e103ec1a926ae5ea089778e6b6d1acf7818a12 /docs/hazmat/primitives/symmetric-encryption.rst
parent0d7aead176dbda689623be89cee68d0649e2aea4 (diff)
downloadcryptography-0f986114004a04cab8fea477e0eace29adab9531.tar.gz
cryptography-0f986114004a04cab8fea477e0eace29adab9531.tar.bz2
cryptography-0f986114004a04cab8fea477e0eace29adab9531.zip
Make the symmetric-enc example an example
Making some minor tweaks to the doc example for symmetric encryption so it is an actual, runable example.
Diffstat (limited to 'docs/hazmat/primitives/symmetric-encryption.rst')
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst4
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 8d3769f5..83230287 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -35,10 +35,12 @@ in an "encrypt-then-MAC" formulation as `described by Colin Percival`_.
.. doctest::
+ >>> import os
>>> from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
>>> from cryptography.hazmat.backends import default_backend
>>> backend = default_backend()
- >>> cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
+ >>> key = os.urandom(24)
+ >>> cipher = Cipher(algorithms.AES(key), modes.CBC(os.urandom(16)), backend=backend)
>>> encryptor = cipher.encryptor()
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
>>> decryptor = cipher.decryptor()