1 � 355žà c
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
# ˆl–ß=¿JJj"Tâ‚ À»p"S�ÿ ƒh¹Á¿Ä 0 $ ˆl–ßi~”J_)�?q°©‹Fÿà „[}ßÂÀÅ -M Fernet (symmetric encryption) ============================= .. currentmodule:: cryptography.fernet Fernet guarantees that a message encrypted using it cannot be manipulated or read without the key. `Fernet`_ is an implementation of symmetric (also known as "secret key") authenticated cryptography. Fernet also has support for implementing key rotation via :class:`MultiFernet`. .. class:: Fernet(key) This class provides both encryption and decryption facilities. .. doctest:: >>> from cryptography.fernet import Fernet >>> key = Fernet.generate_key() >>> f = Fernet(key) >>> token = f.encrypt(b"my deep dark secret") >>> token b'...' >>> f.decrypt(token) b'my deep dark secret' :param key: A URL-safe base64-encoded 32-byte key. This **must** be kept secret. Anyone with this key is able to create and read messages. :type key: bytes or str .. classmethod:: generate_key() Generates a fresh fernet key. Keep this some place safe! If you lose it you'll no longer be able to decrypt messages; if anyone else gains access to it, they'll be able to decrypt all of your messages, and they'll also be able forge arbitrary messages that will be authenticated and decrypted. .. method:: encrypt(data) Encrypts data passed. The result of this encryption is known as a "Fernet token" and has strong privacy and authenticity guarantees. :param bytes data: The message you would like to encrypt. :returns bytes: A secure message that cannot be read or altered without the key. It is URL-safe base64-encoded. This is referred to as a "Fernet token". :raises TypeError: This exception is raised if ``data`` is not ``bytes``. .. note:: The encrypted message contains the current time when it was generated in *plaintext*, the time a message was created will therefore be visible to a possible attacker. .. method:: encrypt_at_time(data, current_time) .. versionadded:: 3.0 Encrypts data passed using explicitly passed current time. See :meth:`encrypt` for the documentation of the ``data`` parameter, the return type and the exceptions raised. The motivation behind this method is for the client code to be able to test token expiration. Since this method can be used in an insecure manner one should make sure the correct time (``int(time.time())``) is passed as ``current_time`` outside testing. :param int current_time: The current time. .. note:: Similarly to :meth:`encrypt` the encrypted message contains the timestamp in *plaintext*, in this case the timestamp is the value of the ``current_time`` parameter. .. method:: decrypt(token, ttl=None) Decrypts a Fernet token. If successfully decrypted you will receive the original plaintext as the result, otherwise an exception will be raised. It is safe to use this data immediately as Fernet verifies that the data has not been tampered with prior to returning it. :param bytes token: The Fernet token. This is the result of calling :meth:`encrypt`. :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``