decrypt method
Implementation
Future<KeyStore> decrypt(String password) async {
try {
var key = initArgon2().argon2(Argon2Arguments(
Uint8List.fromList(utf8.encode(password)),
crypto!.argon2Params!.salt!,
64 * 1024,
1,
32,
4,
2,
13));
final algorithm = cryptography.AesGcm.with256bits();
var entropy = await algorithm.decrypt(
cryptography.SecretBox(
crypto!.cipherData!.sublist(0, crypto!.cipherData!.length - 16),
nonce: crypto!.nonce!,
mac: cryptography.Mac(crypto!.cipherData!.sublist(
crypto!.cipherData!.length - 16, crypto!.cipherData!.length)),
),
secretKey: cryptography.SecretKey(key),
aad: utf8.encode('zenon'));
return KeyStore.fromEntropy(HEX.encode(entropy));
} on SecretBoxAuthenticationError {
throw IncorrectPasswordException();
} catch (e) {
rethrow;
}
}