From 0f986114004a04cab8fea477e0eace29adab9531 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Tue, 30 Dec 2014 09:43:24 -0800 Subject: 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. --- docs/hazmat/primitives/symmetric-encryption.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs/hazmat') 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() -- cgit v1.2.3