sha512-crypt-ts
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -0,11 +1,61 @@ | ||
/** | ||
* SHA-512 crypt compatible module | ||
* @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. Can contain magic prefix. Eg. param `$6$rounds=1000$saltvalue` Will use version 6 of sha-512 with rounds decreased from default 5000 to 1000 and salt = `saltvalue` | ||
*/ | ||
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; | ||
} |
@@ -495,12 +495,61 @@ "use strict"; | ||
}()); | ||
/** | ||
* SHA-512 crypt compatible module | ||
* @preferred | ||
*/ | ||
var sha512; | ||
(function (sha512) { | ||
/** | ||
* Wrapper class based on https://github.com/mvo5/sha512crypt-node implementation. | ||
* This is not intended to be accessible for end-user. | ||
* @internal | ||
*/ | ||
var delegate = new Delegate(); | ||
/** | ||
* 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. Can contain magic prefix. Eg. param `$6$rounds=1000$saltvalue` Will use version 6 of sha-512 with rounds decreased from default 5000 to 1000 and salt = `saltvalue` | ||
*/ | ||
sha512.crypt = function (input, salt) { return delegate.sha512crypt(input, salt); }; | ||
/** | ||
* Compute SHA-512 hash with hexadecimal output | ||
* @param input - Input string to be hashed | ||
*/ | ||
sha512.hex = function (input) { return delegate.rstr2hex(delegate.rstr_sha512(delegate.str2rstr_utf8(input))); }; | ||
/** | ||
* Compute SHA-512 hash with base64 output | ||
* @param input - Input string to be hashed | ||
*/ | ||
sha512.base64 = function (input) { return delegate.rstr2b64(delegate.rstr_sha512(delegate.str2rstr_utf8(input))); }; | ||
/** | ||
* Compute SHA-512 hash with custom alphabet | ||
* @param input - Input string to be hashed | ||
* @param alphabet - Custom alphabet to build result hash | ||
*/ | ||
sha512.any = function (input, alphabet) { return delegate.rstr2any(delegate.rstr_sha512(delegate.str2rstr_utf8(input)), alphabet); }; | ||
/** | ||
* Compute SHA-512 hash as hexadecimal with HMAC digest | ||
* @param key - HMAC key | ||
* @param data - Input data to be hashed | ||
*/ | ||
sha512.hexHmac = function (key, data) { return delegate.rstr2hex(delegate.rstr_hmac_sha512(delegate.str2rstr_utf8(key), delegate.str2rstr_utf8(data))); }; | ||
/** | ||
* Compute SHA-512 hash as base64 with HMAC digest | ||
* @param key - HMAC key | ||
* @param data - Input data to be hashed | ||
*/ | ||
sha512.base64Hmac = function (key, data) { return delegate.rstr2b64(delegate.rstr_hmac_sha512(delegate.str2rstr_utf8(key), delegate.str2rstr_utf8(data))); }; | ||
/** | ||
* Compute SHA-512 hash with HMAC digest and custom alphabet | ||
* @param key - HMAC key | ||
* @param data - Input data to be hashed | ||
* @param alphabet | ||
*/ | ||
sha512.anyHmac = function (key, data, alphabet) { return delegate.rstr2any(delegate.rstr_hmac_sha512(delegate.str2rstr_utf8(key), delegate.str2rstr_utf8(data)), alphabet); }; | ||
/** | ||
* 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) { | ||
@@ -510,2 +559,8 @@ delegate.b64pad = b64pad || ''; | ||
sha512.setBase64Padding = setBase64Padding; | ||
/** | ||
* 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) { | ||
@@ -512,0 +567,0 @@ delegate.hexcase = uppercase ? 1 : 0; |
{ | ||
"name": "sha512-crypt-ts", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Typescript wrapper for SHA-512, including $6$ crypt format.", | ||
@@ -9,3 +9,4 @@ "scripts": { | ||
"coverage": "nyc -r lcov -e .ts -x \"*.test.ts\" npm run test", | ||
"build": "tsc" | ||
"build": "tsc", | ||
"docs": "typedoc --out docs --excludeNotExported" | ||
}, | ||
@@ -49,4 +50,5 @@ "files": [ | ||
"ts-node": "^8.8.2", | ||
"typescript": "^3.8.3" | ||
"typescript": "^3.8.3", | ||
"typedoc": "^0.17.4" | ||
} | ||
} |
@@ -27,1 +27,4 @@ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) | ||
Another examples can be found in [unit tests](https://github.com/bedlaj/sha512-crypt-ts/blob/master/tests/sha512.test.ts) or in peer project [bedlaj/unifi-reset-password](https://github.com/bedlaj/unifi-reset-password/blob/master/src/app/app.component.ts). | ||
#### Documentation | ||
Generated docs can be found at https://bedlaj.github.io/sha512-crypt-ts/latest/modules/_index_.sha512.html (replace `latest` with version number to see older versions) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31039
629
30
10