Creates a new Encryption instance with the provided options
Configuration options for encryption
Reference to the instance of message verifier for signing and verifying values.
Reference to base64 object for base64 encoding/decoding values
The algorithm in use
The encryption algorithm being used
Encrypt a given piece of value using the app secret. A wide range of data types are supported.
You can optionally define a purpose for which the value was encrypted and mentioning a different purpose/no purpose during decrypt will fail.
The data to be encrypted
OptionalexpiresIn: string | numberOptional expiration time
Optionalpurpose: stringOptional purpose for which the value is encrypted
The encrypted payload as a string
Decrypt value and verify it against a purpose
The encrypted value to decrypt
Optionalpurpose: stringOptional purpose that the value was encrypted for
The decrypted data if valid, null if decryption fails
Create a children instance with different secret key
Optionaloptions: EncryptionOptionsOptional configuration options to override
A new Encryption instance with the merged options
The encryption class allows encrypting and decrypting values using
aes-256-cbcoraes-128-cbcalgorithms. The encrypted value uses a unique iv for every encryption and this ensures semantic security (read more https://en.wikipedia.org/wiki/Semantic_security).