Constructor
new SeaSalt_Common(configopt)
Provides a single object with properties leading to each available class. For general use only when directly using the class isn't necessary.
Parameters
User configuration
Properties
Minimum password entropy required
Minimum password character length
Minimum password strength
Logging handler
Default encryption password for encrypting and decrypting strings
Default password hashing class
Default password hashing strength
An instance of SeaSalt_Hashing
An instance of SeaSalt_PWHash_Argon2
An instance of SeaSalt_PWHash_SCrypt
An instance of SeaSalt_AEAD_SecretBox
An instance of SeaSalt_Tools
Example
// most basic usage
let seasalt = new SeaSalt();
// or include a config
let seasalt = new SeaSalt({
minimumKeyLength: 12
});
Methods
aead_test():boolean
Test whether or not AEAD encryption is functioning.
Returns
- Type
- :boolean
Returns true or false.
decrypt(string, secretopt, boxopt):string
Decrypts supplied ciphertext with a known or provided password and optionally a secret box.
Parameters
String to encrypt
Password to use for encryption
Secret box to utilize
Returns
- Type
- :string
Returns the decrypted plaintext.
encrypt(string, secretopt, boxopt):string
Encrypts supplied string with a known or provided password and optionally a secret box.
Parameters
String to encrypt
Password to use for encryption
Secret box to utilize
Returns
- Type
- :string
Returns the encrypted ciphertext.
pwhash_create(password, securityopt, algorithmopt):string
Create a strong password hash using Argon2 or SCrypt.
Parameters
Password to hash
Hashing strength
Hashing algorithm
Returns
- Type
- :string
Returns the password hash.
pwhash_verify(hash, password, algorithmopt):boolean
Checks a password against a password hash to check for validity using Argon2 or SCrypt.
Parameters
Password hash to test against
Password to test
Hashing algorithm
Returns
- Type
- :boolean
Returns true or false.
test():boolean
Test whether or not Sodium is functioning.
Returns
- Type
- :boolean
Returns true or false.