fernetEncrypt method
Encrypts the given value with the provided secretKey using the Fernet encryption algorithm.
Returns a Future that completes with the encrypted value as a Base64-encoded string.
Implementation
Future<String> fernetEncrypt(String secretKey, String value) async {
final key = Key.fromUtf8(secretKey);
final b64key = Key.fromUtf8(base64Url.encode(key.bytes).substring(0, 32));
final fernet = Fernet(b64key);
final encrypter = Encrypter(fernet);
final encrypted = encrypter.encrypt(value);
await SharedPreferencesWrapper.addMap(
EncryptionConstants.encryptionMapKey, {accessKey: secretKey});
return encrypted.base64;
}