decryptAtTime method
Decrypts a token using explicitly passed currentTime
.
See Fernet.decrypt for the documentation
of the token
and ttl
parameters.
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 is passed
as currentTime
outside testing.
Implementation
Uint8List decryptAtTime(dynamic token, int ttl, int currentTime) {
if (token is! Uint8List && token is! String) {
throw ArgumentError('token must be Uint8List or String');
}
final (int timestamp, Uint8List data) =
Fernet._getUnverifiedTokenData(token);
return _decryptData(data, timestamp, [ttl, currentTime]);
}