harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
21 lines (20 loc) • 838 B
TypeScript
export declare const HASH_FUNCTION: {
MD5: string;
SHA256: string;
ARGON2ID: string;
};
type HashFunction = (typeof HASH_FUNCTION)[keyof typeof HASH_FUNCTION];
/**
* Create a hash for the given password (MD5, SHA-256 or argon2id)
* @param password Plain text password
* @param algorithm Hashing algorithm to use (default: SHA-256)
*/
export declare function hash(password: string | Promise<string>, algorithm?: HashFunction): string | Promise<string>;
/**
* Validate a password against a stored hash
* @param storedHash Previously generated hash
* @param password Plain text password to validate
* @param algorithm Hashing algorithm to use (default: SHA-256)
*/
export declare function validate(storedHash: string | Promise<string>, password: string, algorithm?: HashFunction): boolean | Promise<boolean>;
export {};