aboutsummaryrefslogtreecommitdiffstats
path: root/docs/fernet.rst
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-10-31 10:27:35 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-10-31 10:27:35 -0700
commit333fb1024e20fa10ec3e85cbd196cbdff059000d (patch)
treed6ba42f8e01c989a410bd52d79d07c3233fe5a0d /docs/fernet.rst
parentde36e90815f31ec39fe160bf69a81f1bb42b92d2 (diff)
downloadcryptography-333fb1024e20fa10ec3e85cbd196cbdff059000d.tar.gz
cryptography-333fb1024e20fa10ec3e85cbd196cbdff059000d.tar.bz2
cryptography-333fb1024e20fa10ec3e85cbd196cbdff059000d.zip
Docs
Diffstat (limited to 'docs/fernet.rst')
-rw-r--r--docs/fernet.rst48
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/fernet.rst b/docs/fernet.rst
new file mode 100644
index 00000000..938ba0cb
--- /dev/null
+++ b/docs/fernet.rst
@@ -0,0 +1,48 @@
+Fernet
+======
+
+.. currentmodule:: cryptography.fernet
+
+.. testsetup::
+
+ import binascii
+ key = binascii.unhexlify(b"0" * 32)
+
+
+`Fernet`_ is an implementation of symmetric (also known as "secret key")
+authenticated cryptography. Fernet provides guarntees that a message encrypted
+using it cannot be manipulated or read without the key.
+
+.. class:: Fernet(key)
+
+ This class provides both encryption and decryption facilities.
+
+ .. doctest::
+
+ >>> from cryptography.fernet import Fernet
+ >>> f = Fernet(key)
+ >>> ciphertext = f.encrypt(b"my deep dark secret")
+ >>> f.decrypt(ciphertext)
+ 'my deep dark secret'
+
+ :param bytes key: A 32-byte key. This **must** be kept secret. Anyone with
+ this key is able to create and read messages.
+
+
+ .. method:: encrypt(plaintext)
+
+ :param bytes plaintext: The message you would like to encrypt.
+ :returns bytes: A secure message which cannot be read or altered
+ without the key.
+
+ .. method:: decrypt(ciphertext, ttl=None)
+
+ :param bytes ciphertext: An encrypted message.
+ :param int ttl: Optionally, the number of seconds old a message may be
+ for it to be valid. If the message is older than
+ ``ttl`` seconds (from the time it was originally
+ created) an exception will be raised.
+ :returns bytes: The original plaintext.
+
+
+.. _`Fernet`: https://github.com/fernet/spec/