node-hash-password
Version:
Hash your password before storing it on database with node.js
60 lines (56 loc) • 1.82 kB
TypeScript
type TypeHash = `keccak256` | `sha256` | `sha512`;
type TypeCompare = {
method: TypeHash;
hash: string;
password: string;
};
declare const to8bytes: (v: any) => Uint8Array;
/**
*
* @password string plain text
* @returns string hash with prefix 0x
*/
declare const hashWithKeccak256: (password: string) => string;
/**
*
* @password string plain text
* @returns string hash with prefix 0x
*/
declare const hashWithSha256: (password: string) => string;
/**
*
* @password string plain text
* @returns string hash with prefix 0x
*/
declare const hashWithSha512: (password: string) => string;
/**
*
* @method string. algoritma method example keccak256, sha256, sha512
* @hash string. result from algoritma hash
* @password string. your pure password plain text
* @returns boolean. if true password and hash is match
*/
declare const compareHashAndPassword: (param: TypeCompare) => boolean;
/**
*
* @todo automate find algoritma hash and compare it if equal with return "true" otherwise "false"
* @hash string. result from algoritma hash
* @password string. your pure password plain text
* @returns boolean. if "true" password and hash is match
*/
declare const compareHashAndPasswordAuto: (param: {
hash: string;
password: string;
}) => boolean;
declare const _default: {
to8bytes: (v: any) => Uint8Array;
hashWithKeccak256: (password: string) => string;
hashWithSha256: (password: string) => string;
hashWithSha512: (password: string) => string;
compareHashAndPassword: (param: TypeCompare) => boolean;
compareHashAndPasswordAuto: (param: {
hash: string;
password: string;
}) => boolean;
};
export { compareHashAndPassword, compareHashAndPasswordAuto, _default as default, hashWithKeccak256, hashWithSha256, hashWithSha512, to8bytes };