hashPassword()function
hashPassword(password: string, iterations = ITERATIONS): Promise<string>
| Param | Type | |
|---|---|---|
password | string | The password to hash. required |
iterations | unknown | The number of iterations. Defaults to ITERATIONS |
| Return | |
|---|---|
Promise<string> | Hash in the format salt$iterations$hash, where salt and hash are base64-encoded.- Returned hash tring will be about 128 characters long (16 byte salt + iteration count + 64 byte hash + 2 separators = 116 characters once base64 encoded). |
| Throws | |
|---|---|
ValueError | If the password is shorter than the minimum length, or iterations is less than 1. |
Hash a password using PBKDF2, generating a new salt, and return the combined salt$iterations$hash string.
Examples
const hash = await hashPassword("correct-horse"); // "abc…$500000$def…"