sha512-crypt-ts
Version:
Typescript wrapper for SHA-512, including $6$ crypt format.
63 lines (62 loc) • 2.39 kB
TypeScript
/**
* SHA-512, supporting hex, base64, crypt and HMAC hashes
* @preferred
*/
export declare module sha512 {
/**
* Compute SHA-512 hash compatible with crypt implementation (`mkpasswd --method=sha-512`)
* @param input - Input string to be hashed
* @param salt - Salt to be used with algorithm. Salt length must be between 8 and 16 characters. Can contain magic prefix. Eg. param `$6$rounds=1000$saltvalue` Will use rounds decreased from default 5000 to 1000 and salt = `saltvalue`
* @throws Error if input values validation fails
*/
const crypt: (input: string, salt: string) => string;
/**
* Compute SHA-512 hash with hexadecimal output
* @param input - Input string to be hashed
*/
const hex: (input: string) => string;
/**
* Compute SHA-512 hash with base64 output
* @param input - Input string to be hashed
*/
const base64: (input: string) => string;
/**
* Compute SHA-512 hash with custom alphabet
* @param input - Input string to be hashed
* @param alphabet - Custom alphabet to build result hash
*/
const any: (input: string, alphabet: string) => string;
/**
* Compute SHA-512 hash as hexadecimal with HMAC digest
* @param key - HMAC key
* @param data - Input data to be hashed
*/
const hexHmac: (key: string, data: string) => string;
/**
* Compute SHA-512 hash as base64 with HMAC digest
* @param key - HMAC key
* @param data - Input data to be hashed
*/
const base64Hmac: (key: string, data: string) => string;
/**
* Compute SHA-512 hash with HMAC digest and custom alphabet
* @param key - HMAC key
* @param data - Input data to be hashed
* @param alphabet
*/
const anyHmac: (key: string, data: string, alphabet: string) => string;
/**
* Set padding character for base64 output. Set `=` to be strictly compliant with RFC-4648.
* Default padding is empty string.
* This is global per-module option.
* @param b64pad - Base64 padding character
*/
function setBase64Padding(b64pad?: string): void;
/**
* Set HexCase for hex based methods.
* Default is false.
* This is global per-module option.
* @param uppercase - true for uppercase output, false for lowercase output.
*/
function setHexCase(uppercase?: boolean): void;
}