AesCipher class final

AES-256-GCM authenticated encryption cipher for quantum_cache.

Security properties:

  • Key: 256-bit (32 bytes) — brute-force resistant.
  • Mode: GCM (Galois/Counter Mode) — provides both confidentiality and authenticity. Any tampered ciphertext is detected and rejected.
  • IV/Nonce: 96-bit (12 bytes) — randomly generated per encryption call. Using a fresh nonce each time prevents nonce-reuse attacks.
  • Auth tag: 128-bit (16 bytes) — appended to the ciphertext.

Wire format:

[ 12 bytes ] IV (random nonce)
[ n bytes  ] AES-256-CTR encrypted payload
[ 16 bytes ] GCM authentication tag

Total overhead per value: 28 bytes.

Usage:

final key = AesCipher.generateKey(); // save this securely!
await SuperCache.init(
  config: CacheConfig(encryptionKey: key),
);
Implemented types

Constructors

AesCipher(List<int> key)
Creates an AesCipher with the given 32-byte key.

Properties

algorithmName String
Human-readable name of this cipher (used in debug output).
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(Uint8List ciphertext) Uint8List
Decrypts ciphertext and returns the original plaintext.
override
encrypt(Uint8List plaintext) Uint8List
Encrypts plaintext and returns the ciphertext.
override
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

Static Methods

deriveKey(String password, List<int> salt, {int iterations = 100000}) List<int>
Derives a 32-byte key from a password and salt using PBKDF2-SHA256.
generateKey() List<int>
Generates a cryptographically random 32-byte AES-256 key.