Fernet class

This class provides both encryption and decryption facilities.

Constructors

Fernet(dynamic key)
key is URL-safe base64-encoded and it has to be 32-bytes long before base64-encoding. This must be kept secret. Anyone with this key is able to create and read messages.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(dynamic token, {int? ttl}) Uint8List
Decrypts a fernet token. If successful you will receive the original plaintext as the result, otherwise an exception will be thrown. It is safe to use this data immediately as Fernet verifies that the data has not been tampered with prior to returning it.
decryptAtTime(dynamic token, int ttl, int currentTime) Uint8List
Decrypts a token using explicitly passed currentTime. See Fernet.decrypt for the documentation of the token and ttl parameters.
encrypt(Uint8List data) Uint8List
Encrypts data passed. The result of this encryption is known as a "Fernet token" and has strong privacy and authenticity guarantees.
encryptAtTime(Uint8List data, int currentTime) Uint8List
Encrypts data passed using explicitly passed currentTime. See Fernet.encrypt for the documentation of the data parameter.
extractTimeStamp(dynamic token) int
Returns the Unix timestamp for the token. The caller can then decide if the token is about to expire and, for example, issue a new token.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

generateKey() String
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.