encryptBytes static method
Criptografa bytes com ChaCha20-Poly1305 e retorna um EncryptedPayload.
key: 32 bytes. Se omitido, gera uma chave aleatória segura.nonce: 12 bytes. Se omitido, gera um nonce aleatório seguro.aad: dados autenticados mas não cifrados (opcional).
Implementation
static EncryptedPayload encryptBytes(
List<int> bytes, {
Uint8List? key,
Uint8List? nonce,
List<int>? aad,
}) {
final cipher = ChaCha20Poly1305(
key: key ?? generateKey(),
nonce: nonce ?? generateNonce(),
aad: aad != null ? Uint8List.fromList(aad) : Uint8List(0),
);
return cipher.encrypt(bytes);
}