You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to use this package in Flutter Flow, but I get an ArgumentError when the secret key is invalid. The code is below.
Future<String?> decryptString(String ciphertext, String secretKeyB64) async {
if (ciphertext.split(';').length !=3) {
returnnull;
}
final secretKey =SecretKey(convert.Base64Decoder().convert(secretKeyB64));
final algo =Chacha20(macAlgorithm:Hmac.sha256());
var [nonceStr, ctStr, macStr] = ciphertext.split(';');
final nonce = convert.Base64Decoder().convert(nonceStr);
final ct = convert.Base64Decoder().convert(ctStr);
final mac = convert.Base64Decoder().convert(macStr);
final box =SecretBox(ct, nonce: nonce, mac:Mac(mac));
try {
await box
.checkMac(macAlgorithm:Hmac.sha256(), secretKey: secretKey, aad: []);
} onException {
returnnull;
} onArgumentError {
returnnull;
}
final pt =await algo.decrypt(box, secretKey: secretKey);
return convert.Utf8Decoder().convert(pt);
}
When I run similar code from the console and supply the wrong key, it instead throws an authentication error.
Not sure if there is a versioning issue with the dependencies or just a platform difference, but it does not make sense to require an argument and then not support it.
The text was updated successfully, but these errors were encountered:
k98kurz
changed the title
Argument Error: add not supported, but it is a required argument
Argument Error: aad not supported, but it is a required argument
Aug 24, 2023
Trying to use this package in Flutter Flow, but I get an ArgumentError when the secret key is invalid. The code is below.
When I run similar code from the console and supply the wrong key, it instead throws an authentication error.
Not sure if there is a versioning issue with the dependencies or just a platform difference, but it does not make sense to require an argument and then not support it.
The text was updated successfully, but these errors were encountered: