SeaSalt_PWHash_Argon2


SeaSalt_PWHash_Argon2

Creates a Argon2 hash of the provided password with optional security level.

Requires the Sodium Sumo distribution

Constructor

new SeaSalt_PWHash_Argon2()

Methods

create(password, securityopt):string

Parameters
password:string

Password to hash

security:string = normal (optional)

Security level to hash with

Returns
Type
:string

Returns the Argon2 hash of the supplied password.

Example
let argon2 = new SeaSalt_PWHash_Argon2();
argon2.create('myterriblepassword');

//  returns the argon2 string like: $argon2id$v=19$m=65536,t=4,p=1$Vp+2jMiZyshaDgdVWDBRiQ$zOQo/pYHko7cZpKo9ptgBKGd4oJgCzOoRJa7FiPDRqA

verify(hash, password):boolean

Verify if a password matches an Argon2 hash.

Parameters
hash:string

Argon2 hash

password:string

User password

Returns
Type
:boolean
Example
//  using the example from argon2.create
let argon2 = new SeaSalt_PWHash_Argon2();
argon2.verify('$argon2id$v=19$m=65536,t=4,p=1$Vp+2jMiZyshaDgdVWDBRiQ$zOQo/pYHko7cZpKo9ptgBKGd4oJgCzOoRJa7FiPDRqA', 'myterriblepassword');