CryptoUtils class

Cryptographic utilities for secure key management.

Security Features:

  • PBKDF2-HMAC-SHA256 with configurable iterations (default 100,000)
  • AES-256-GCM authenticated encryption
  • Memory zeroing for sensitive data
  • Cryptographically secure random generation
  • Constant-time comparison

Constructors

CryptoUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

constantTimeEquals(Uint8List a, Uint8List b) bool
Constant-time comparison to prevent timing attacks.
decrypt(EncryptedData encrypted, Uint8List key) Future<Uint8List>
Decrypts AES-256-GCM encrypted data.
deriveKey(String password, Uint8List salt, {int iterations = defaultIterations, int keyLength = keySize}) Uint8List
Derives a key from a password using PBKDF2-HMAC-SHA256.
encrypt(Uint8List plaintext, Uint8List key) Future<EncryptedData>
Encrypts data using AES-256-GCM.
generateSalt() Uint8List
Generates a random salt for PBKDF2.
randomBytes(int length) Uint8List
Generates cryptographically secure random bytes.
zeroMemory(Uint8List buffer) → void
Zeros a memory buffer to prevent sensitive data from lingering.

Constants

defaultIterations → const int
Default PBKDF2 iteration count.
keySize → const int
AES key size in bytes (256 bits).
nonceSize → const int
AES-GCM nonce size in bytes (96 bits).
saltSize → const int
PBKDF2 salt size in bytes.
tagSize → const int
AES-GCM authentication tag size in bytes (128 bits).