AesGcm class

Implementação do cipher autenticado AES-GCM (AEAD) — NIST SP 800-38D.

Equivalente moderno ao ChaCha20-Poly1305 para casos que exigem AES.

final key = CryptUtil.generateKey(); // 32 bytes → AES-256
final nonce = Uint8List(12);
Random.secure().nextBytes(nonce);

final gcm = AesGcm(key: key, nonce: nonce, aad: Uint8List(0));
final payload = gcm.encrypt(utf8.encode('texto secreto'));
final texto = utf8.decode(gcm.decrypt(payload));

Constructors

AesGcm({required Uint8List key, required Uint8List nonce, required Uint8List aad})
const

Properties

aad Uint8List
final
hashCode int
The hash code for this object.
no setterinherited
key Uint8List
final
nonce Uint8List
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(EncryptedPayload payload) List<int>
Decifra payload e retorna o plaintext original.
encrypt(List<int> plaintext) EncryptedPayload
Cifra plaintext e retorna um EncryptedPayload com ciphertext e tag GCM.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

nonceLength → const int
tagLength → const int