aboutsummaryrefslogtreecommitdiffstats
path: root/docs/primitives
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-08-08 15:19:19 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-08-08 15:19:19 -0700
commit65678d05febd580daf00b520dbf7ce943f47bb66 (patch)
treec32cb12d57bd802a90a2ec23fd9ac69edbefd658 /docs/primitives
parent6badd9b99b68cbd35f0e9b7d164c45b1696f08d3 (diff)
downloadcryptography-65678d05febd580daf00b520dbf7ce943f47bb66.tar.gz
cryptography-65678d05febd580daf00b520dbf7ce943f47bb66.tar.bz2
cryptography-65678d05febd580daf00b520dbf7ce943f47bb66.zip
Document this as a class
Diffstat (limited to 'docs/primitives')
-rw-r--r--docs/primitives/symmetric-encryption.rst35
1 files changed, 17 insertions, 18 deletions
diff --git a/docs/primitives/symmetric-encryption.rst b/docs/primitives/symmetric-encryption.rst
index 39a5a630..d056290e 100644
--- a/docs/primitives/symmetric-encryption.rst
+++ b/docs/primitives/symmetric-encryption.rst
@@ -4,29 +4,28 @@ Symmetric Encryption
Symmetric encryption is a way to encrypt (hide the plaintext value) material
where the encrypter and decrypter both use the same key.
-Block ciphers
--------------
+.. class:: cryptography.primitives.block.BlockCipher(cipher, mode)
-Block ciphers work by encrypting content in chunks, often 64- or 128-bits. 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:
+ Block ciphers work by encrypting content in chunks, often 64- or 128-bits.
+ Theycombine 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
+ .. code-block:: pycon
- >>> from cryptography.primitives.block import BlockCipher, cipher, mode
- >>> cipher = BlockCipher(cipher.AES(key), mode.CBC(iv))
- >>> cipher.encrypt("my secret message") + cipher.finalize()
- # The ciphertext
- [...]
+ >>> from cryptography.primitives.block import BlockCipher, cipher, mode
+ >>> cipher = BlockCipher(cipher.AES(key), mode.CBC(iv))
+ >>> cipher.encrypt("my secret message") + cipher.finalize()
+ # The ciphertext
+ [...]
-Here ``key`` is the encryption key (which must be kept secret), and ``iv`` is
-the initialization vector (which must be random). Exactly what form these
-values should take is described for each of the ciphers and modes.
+ Here ``key`` is the encryption key (which must be kept secret), and ``iv``
+ is the initialization vector (which must be random). Exactly what form
+ these values should take is described for each of the ciphers and modes.
-``encrypt()`` should be called repeatedly with additional plaintext, and it
-will return the encrypted bytes, if there isn't enough data, it will buffer it
-internally. ``finalize()`` should be called at the end, and will return
-whatever data is left.
+ ``encrypt()`` should be called repeatedly with additional plaintext, and it
+ will return the encrypted bytes, if there isn't enough data, it will buffer
+ it internally. ``finalize()`` should be called at the end, and will return
+ whatever data is left.
Ciphers
~~~~~~~