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)

75 lines (74 loc) 2 kB
import { type IDataType } from "./util"; export interface IArgon2Options { /** * Password (or message) to be hashed */ password: IDataType; /** * Salt (usually containing random bytes) */ salt: IDataType; /** * Secret for keyed hashing */ secret?: IDataType; /** * Number of iterations to perform */ iterations: number; /** * Degree of parallelism */ parallelism: number; /** * Amount of memory to be used in kibibytes (1024 bytes) */ memorySize: number; /** * Output size in bytes */ hashLength: number; /** * Desired output type. Defaults to 'hex' */ outputType?: "hex" | "binary" | "encoded"; } interface IArgon2OptionsBinary { outputType: "binary"; } type Argon2ReturnType<T> = T extends IArgon2OptionsBinary ? Uint8Array : string; /** * Calculates hash using the argon2i password-hashing function * @returns Computed hash */ export declare function argon2i<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>; /** * Calculates hash using the argon2id password-hashing function * @returns Computed hash */ export declare function argon2id<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>; /** * Calculates hash using the argon2d password-hashing function * @returns Computed hash */ export declare function argon2d<T extends IArgon2Options>(options: T): Promise<Argon2ReturnType<T>>; export interface Argon2VerifyOptions { /** * Password to be verified */ password: IDataType; /** * Secret used on hash creation */ secret?: IDataType; /** * A previously generated argon2 hash in the 'encoded' output format */ hash: string; } /** * Verifies password using the argon2 password-hashing function * @returns True if the encoded hash matches the password */ export declare function argon2Verify(options: Argon2VerifyOptions): Promise<boolean>; export {};