AESEncryptor class
Encrypt and decrypt text with AES-GCM.
Each message gets a new random 12-byte nonce.
The output is base64 of nonce + ciphertext + tag.
The 16-byte tag lets decode find any change to the text.
associatedData binds the text to a context, like a cookie name.
It is not stored in the output. decode needs the same value, or it
fails. So a value made for one cookie can not be used as another.
The AES key is not the secret itself. It is made from the secret and
a purpose label with HKDF-SHA256 (see KeyDerivation). Cookies use
the label dox:cookie, other values dox:encrypt by default. A value
made for one purpose can not be read with another one.
Constructors
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
-
decode(
String content, String secret, {String associatedData = '', String purpose = KeyDerivation.encrypt}) → String - decode a message. Throws DecryptException when the text was changed or the key is wrong.
-
encode(
String content, String secret, {String associatedData = '', String purpose = KeyDerivation.encrypt}) → String - encode a message