UNPKG

hash-wasm

Version:

Lightning fast hash functions for browsers and Node.js using hand-tuned WebAssembly binaries (MD4, MD5, SHA-1, SHA-2, SHA-3, Keccak, BLAKE2, BLAKE3, PBKDF2, Argon2, bcrypt, scrypt, Adler-32, CRC32, CRC32C, RIPEMD-160, HMAC, xxHash, SM3, Whirlpool)

45 lines (44 loc) 1.23 kB
import { type IDataType } from "./util"; export interface BcryptOptions { /** * Password to be hashed */ password: IDataType; /** * Salt (16 bytes long - usually containing random bytes) */ salt: IDataType; /** * Number of iterations to perform (4 - 31) */ costFactor: number; /** * Desired output type. Defaults to 'encoded' */ outputType?: "hex" | "binary" | "encoded"; } interface IBcryptOptionsBinary { outputType: "binary"; } type BcryptReturnType<T> = T extends IBcryptOptionsBinary ? Uint8Array : string; /** * Calculates hash using the bcrypt password-hashing function * @returns Computed hash */ export declare function bcrypt<T extends BcryptOptions>(options: T): Promise<BcryptReturnType<T>>; export interface BcryptVerifyOptions { /** * Password to be verified */ password: IDataType; /** * A previously generated bcrypt hash in the 'encoded' output format */ hash: string; } /** * Verifies password using bcrypt password-hashing function * @returns True if the encoded hash matches the password */ export declare function bcryptVerify(options: BcryptVerifyOptions): Promise<boolean>; export {};