encryptAesGcm static method
Criptografa bytes com AES-GCM e retorna um EncryptedPayload.
key: 16 bytes (AES-128) ou 32 bytes (AES-256). Padrão: 32 bytes.nonce: 12 bytes. Se omitido, gera um nonce aleatório seguro.aad: dados autenticados mas não cifrados (opcional).
final payload = CryptUtil.encryptAesGcm(dados, key: key);
final plain = CryptUtil.decryptAesGcm(payload);
Implementation
static EncryptedPayload encryptAesGcm(
List<int> bytes, {
Uint8List? key,
Uint8List? nonce,
List<int>? aad,
}) =>
AesGcm(
key: key ?? generateKey(),
nonce: nonce ?? generateNonce(),
aad: aad != null ? Uint8List.fromList(aad) : Uint8List(0),
).encrypt(bytes);