Constructor
new SeaSalt_AEAD_XChaCha(stringopt, secretopt, boxopt, configopt)
Parameters
String to encrypt
Password to use for encryption
Secret box to use with encryption
Configuration data
Properties
Secret box utilized in encryption
Ciphertext generated by the most recent encryption request
AEAD Encryption Configuration
Minimum password entropy required
Minimum password character length
Minimum password strength
Logging handler
Methods
decrypt(string, secret, boxopt):string
Decrypts a string optionally using a secret box.
Using a secret box allows you to let a user change passwords without needing to rewrite all encrypted data.
See SeaSalt_AEAD_SecretBox for more information.
Parameters
String to encrypt
Password to use for encryption
Secret box ciphertext or instance
Returns
- Type
- :string
Returns the decrypted plaintext
Examples
// using the result from the example at keychain.encrypt
let aead = new SeaSalt_AEAD_XChaCha();
aead.decrypt('00002c4cdbf646c1bba6c3f543a104e78555069f3bf5ca09fc5b66c7201eca012d10f01cdf49c15654ec418f7cac0cd5a6b1d0', 'mybestsecretevar33');
// returns a string like: Hello world
// this time we'll use a secret box
let secretbox = new SeaSalt_AEAD_SecretBox('mybestsecretevar33', aead.key());
aead.encrypt('Hello world', 'mybestsecretevar33', secretbox);
// the user password opens a secret box which contains the actual encryption key
encrypt(string, secret, boxopt):string
Encrypts a string optionally using a secret box.
Each encryption has a unique nonce. The same string will never encrypt to the same ciphertext twice.
Using a secret box allows you to let a user change passwords without needing to rewrite all encrypted data.
See SeaSalt_AEAD_SecretBox for more information.
Parameters
String to encrypt
Password to use for encryption
Secret box ciphertext or instance
Returns
- Type
- :string
Returns the encrypted ciphertext
Examples
let aead = new SeaSalt_AEAD_XChaCha();
aead.encrypt('Hello world', 'mybestsecretevar33');
// ciphertext in aead.ciphertext reads: 00002c4cdbf646c1bba6c3f543a104e78555069f3bf5ca09fc5b66c7201eca012d10f01cdf49c15654ec418f7cac0cd5a6b1d0
// this time we'll use a secret box
let secretbox = new SeaSalt_AEAD_SecretBox('mybestsecretevar33', aead.key());
aead.encrypt('Hello world', 'mybestsecretevar33', secretbox);
// the user password opens a secret box which contains the actual encryption key
key():string
Generates a unique AEAD encryption key in hex format.
Returns
- Type
- :string
toJSON():string
Generate a JSON string containing encryption results
Returns
- Type
- :string