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
Properties
- aad → Uint8List
-
Dados adicionais autenticados, preservados em texto claro.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Uint8List
-
Chave AES de 16 bytes (AES-128) ou 32 bytes (AES-256).
final
- nonce → Uint8List
-
Nonce de nonceLength bytes, que deve ser único para cada mensagem.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decrypt(
EncryptedPayload payload) → List< int> -
Decifra
payloade retorna o plaintext original. -
encrypt(
List< int> plaintext) → EncryptedPayload -
Cifra
plaintexte 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
- Tamanho obrigatório do nonce GCM, em bytes.
- tagLength → const int
- Tamanho da tag de autenticação produzida pelo GCM, em bytes.