decrypt method
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.
ttl (optional) is 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 thrown.
If ttl is not provided (or is null),
the age of the message is not considered.
Implementation
Uint8List decrypt(final dynamic token, {final int? ttl}) {
if (token is! Uint8List && token is! String) {
throw ArgumentError('token must be Uint8List or String');
}
final (int timestamp, Uint8List data) = Fernet._getUnverifiedTokenData(
token,
);
List<int>? timeInfo;
if (ttl != null) {
timeInfo = [ttl, DateTime.now().millisecondsSinceEpoch ~/ 1000];
}
return _decryptData(data, timestamp, timeInfo);
}