chaCha20Poly1305Decrypt static method
Decrypt data using the ChaCha20-Poly1305 authenticated encryption algorithm. Requires a key, nonce, ciphertext, and optional associated data.
Implementation
static List<int> chaCha20Poly1305Decrypt({
required List<int> key,
required List<int> nonce,
required List<int> cipherText,
List<int>? assocData,
}) {
final chacha = ChaCha20Poly1305(key);
try {
final decrypt = chacha.decrypt(
nonce,
cipherText,
associatedData: assocData,
);
if (decrypt != null) {
return decrypt;
}
throw CryptoException.failed(
"chaCha20Poly1305Decrypt",
reason: "Decryption failed.",
);
} finally {
chacha.clean();
}
}