UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

22 lines (21 loc) 1.08 kB
/** Get random bytes from the crypto API. */ export declare function getRandomBytes(length: number): Uint8Array; /** * Hash a password using PBKDF2, generating a new salt, and return the combined salt$iterations$hash string. * * @param password The password to hash. * @param iterations The number of iterations. * * @returns 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). */ export declare function hashPassword(password: string, iterations?: number): Promise<string>; /** * Verify a password against a stored salt$iterations$hash string using PBKDF2. * * @param password The password to verify. * @param hash String in the format `salt$iterations$hash`, where `salt` and `hash` are base64-encoded. * * @returns True if the password matches the hash, false otherwise. */ export declare function verifyPassword(password: string, hash: string): Promise<boolean>;