EncryptionUtil class

A utility class for AES-256 encryption and decryption.

Constructors

EncryptionUtil(String base64Key, String base64Iv)
Creates an EncryptionUtil with the provided base64 encoded key and IV.

Properties

hashCode → int
The hash code for this object.
no setterinherited
iv → IV
The initialization vector (must be 16 bytes).
final
key → Key
The encryption key (must be 32 bytes for AES-256).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

decryptToJson(String base64) → dynamic
Decrypts a base64 string back to a JSON object.
decryptToString(String base64) → String
Decrypts a base64 string back to a plain string.
encryptJson(dynamic obj) → String
Encrypts a JSON-serializable object.
encryptString(String plainText) → String
Encrypts a simple string.
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 Properties

instance → EncryptionUtil
Default instance using a fixed key for easy demo purposes.
final

Static Methods

decrypt(String base64) → String
Alias for decryptToString using the default instance.
encrypt(String plainText) → String
Alias for encryptString using the default instance.
randomBase64Iv() → String
Generates a random 16-byte base64 encoded IV.
randomBase64Key() → String
Generates a random 32-byte base64 encoded key.