From 173de98d630b77583d4541e399b164cc2eb014a7 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Mon, 12 Aug 2013 07:34:39 -0400 Subject: Test the symmetric encryption doc snippets using doctest --- docs/primitives/symmetric-encryption.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst index 9986d89d..1b8d1d73 100644 --- a/docs/primitives/symmetric-encryption.rst +++ b/docs/primitives/symmetric-encryption.rst @@ -1,6 +1,13 @@ Symmetric Encryption ==================== +.. testsetup:: + + import binascii + key = binascii.unhexlify(b"0" * 32) + iv = binascii.unhexlify(b"0" * 32) + + Symmetric encryption is a way to encrypt (hide the plaintext value) material where the encrypter and decrypter both use the same key. @@ -10,13 +17,12 @@ where the encrypter and decrypter both use the same key. They combine an underlying algorithm (such as AES), with a mode (such as CBC, CTR, or GCM). A simple example of encrypting content with AES is: - .. code-block:: pycon + .. doctest:: >>> from cryptography.primitives.block import BlockCipher, ciphers, modes >>> cipher = BlockCipher(ciphers.AES(key), modes.CBC(iv)) >>> cipher.encrypt(b"a secret message") + cipher.finalize() - # The ciphertext - [...] + '...' :param cipher: One of the ciphers described below. :param mode: One of the modes described below. -- cgit v1.2.3