diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-01-04 07:52:33 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-01-04 07:52:33 -0600 |
commit | 0205162f29da7baa8cffb83f4e0401d4ebbacfbe (patch) | |
tree | 4b902c169a8322019e435d2e10fb9af42355951d | |
parent | aac0928f1a1e5690f2a081947134cac04de10086 (diff) | |
parent | e5917781674c3678589571621c9b18153d2140b5 (diff) | |
download | cryptography-0205162f29da7baa8cffb83f4e0401d4ebbacfbe.tar.gz cryptography-0205162f29da7baa8cffb83f4e0401d4ebbacfbe.tar.bz2 cryptography-0205162f29da7baa8cffb83f4e0401d4ebbacfbe.zip |
Merge pull request #1593 from greghaynes/feature/make-symmetric-enc-example-an-example
Make the symmetric-enc example an example
-rw-r--r-- | docs/hazmat/primitives/symmetric-encryption.rst | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst index 8d3769f5..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 @@ -35,9 +29,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() + >>> 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() |