Encryption class

Enhanced encryption utilities for database security

This class provides various encryption and hashing methods for securing sensitive data in the database.

Example usage:

final encryption = Encryption();

// Hash a password
final hashedPassword = encryption.hashPassword('myPassword123');

// Encrypt sensitive data
final encrypted = encryption.encrypt('sensitive data', 'secretKey');
final decrypted = encryption.decrypt(encrypted, 'secretKey');

// Generate secure tokens
final token = encryption.generateToken();

Constructors

Encryption.new()

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

checkPasswordStrength(String password) Map<String, dynamic>
Check password strength
decrypt(String encryptedData, String key) String
Decrypt data using AES-256-GCM
encrypt(String data, String key, {String? associatedData}) String
Encrypt data using AES-256-GCM
generatePassword({int length = 16, bool includeUppercase = true, bool includeLowercase = true, bool includeNumbers = true, bool includeSymbols = true}) String
Generate a secure password
generateToken([int length = 32]) String
Generate a secure random token
generateUuid() String
Generate a secure random UUID
hashPassword(String password, {String? salt, int iterations = _defaultIterations, int keyLength = _defaultKeyLength}) Map<String, String>
Hash a password using PBKDF2 with salt
hashSha256(String data) String
Hash data using SHA-256
hashSha512(String data) String
Hash data using SHA-512
hmac(String data, String key, {String algorithm = 'sha256'}) String
Generate a hash-based message authentication code (HMAC)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
verifyPassword(String password, String hash, String salt, int iterations, int keyLength) bool
Verify a password against a stored hash

Operators

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