Constructor
new SeaSalt_AEAD_SecretBox(userPasswordopt, secretItemopt, configopt)
Parameters
Password for the secret box
Item to store inside the secret box
User-provided Configuration data
At a basic level this is a glorified encrypted string.
A typical usage for a secret box is to store an AEAD encryption key. The password on the secret box can change without requiring any encrypted data be re-encrypted.
You can also store a JSON object with any data you want along with an encryption key.
Properties
Secret box ciphertext once generated
Configuration data
Logging handler
Minimum password entropy required
Minimum password character length
Minimum password strength
Methods
check(box, userPassword, secretItemopt):boolean
Check if a secret box is valid and/or readable.
Parameters
Secret box to repackage
Password of the existing secret box
Item to check for inside the secret box
Returns
- Type
- :boolean
Returns true or false
Example
// using the result from the example in keychain.create
let secretbox = new SeaSalt_AEAD_SecretBox();
secretbox.check('077eb44fc4d04ad6093f6ab5c1938c151c07fd9fb360234670a7e0da4530aa3f...', 'mygreatpassword1');
// result would return true or false
create(userPassword, secretItem):string
Create a secret box with the provided item.
Parameters
Password for the secret box
Item to place inside the box
Returns
- Type
- :string
Returns the secret box ciphertext.
Examples
let aead = new SeaSalt_AEAD_XChaCha();
let secretbox = new SeaSalt_AEAD_SecretBox();
secretbox.create('mygreatpassword1', aead.key());
// returns a string like: 077eb44fc4d04ad6093f6ab5c1938c151c07fd9fb360234670a7e0da4530aa3f...
let aead = new SeaSalt_AEAD_XChaCha();
let secretbox = new SeaSalt_AEAD_SecretBox();
secretbox.create('mygreatpassword1', aead.key());
let ciphertext = aead.encrypt('My great string', 'mygreatpassword1', secretbox);
// returns the encrypted ciphertext using the encryption key stored in the secret box
repackage(box, userPassword, newPassword):string
Repackages a secret box and optionally changes its password.
This will re-encrypt the contents of a secret box resulting in new secret box ciphertext.
Parameters
Secret box to repackage
Password of the existing secret box
New password to set on the secret box
Returns
- Type
- :string
Returns the secret box ciphertext.
Example
let secretbox = new SeaSalt_AEAD_SecretBox('mygreatpassword1', aead.key());
// repackage with same password
secretbox.repackage('mygreatpassword1');
// repackage with new password
secretbox.repackage('mygreatpassword1', 'evenbettarp4ssword');
// repackage with a supplied box
secretbox.repackage('077eb44fc4d04ad6093f6ab5c1938c151c07fd9fb360234670a7e0da4530aa3f...', 'mygreatpassword1');
toString():string
Returns the secret box ciphertext.
Returns
- Type
- :string