@appolo/utils
Advanced tools
Comparing version 8.0.14 to 8.0.15
@@ -11,3 +11,3 @@ "use strict"; | ||
static hashPlainObject(obj, algorithm = 'sha1', encoding = 'hex') { | ||
return Hash.hash(strings_1.Strings.stringifyObjectValues(obj)); | ||
return Hash.hash(strings_1.Strings.stringifyObjectValues(obj), algorithm, encoding); | ||
} | ||
@@ -14,0 +14,0 @@ static md5(str) { |
import {Strings} from '../strings'; | ||
import {BinaryLike, createHash, HexBase64Latin1Encoding} from "crypto"; | ||
import {BinaryLike, createHash, BinaryToTextEncoding} from "crypto"; | ||
export class Hash { | ||
public static hash(value: BinaryLike, algorithm: string = 'sha1', encoding: HexBase64Latin1Encoding = 'hex'): string { | ||
public static hash(value: BinaryLike, algorithm: string = 'sha1', encoding: BinaryToTextEncoding = 'hex'): string { | ||
return createHash(algorithm).update(value).digest(encoding); | ||
} | ||
public static hashPlainObject(obj: { [index: string]: string | number | boolean }, algorithm: string = 'sha1', encoding: HexBase64Latin1Encoding = 'hex'): string { | ||
return Hash.hash(Strings.stringifyObjectValues(obj)); | ||
public static hashPlainObject(obj: { [index: string]: string | number | boolean }, algorithm: string = 'sha1', encoding: BinaryToTextEncoding = 'hex'): string { | ||
return Hash.hash(Strings.stringifyObjectValues(obj),algorithm,encoding); | ||
} | ||
@@ -14,0 +14,0 @@ |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.14", | ||
"version": "8.0.15", | ||
"license": "MIT", | ||
@@ -33,18 +33,13 @@ "repository": { | ||
"devDependencies": { | ||
"@types/benchmark": "^1.0.33", | ||
"@types/bluebird": "^3.5.32", | ||
"@types/chai": "^4.2.12", | ||
"@types/lodash": "^4.14.159", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^14.6.0", | ||
"aes256": "^1.0.4", | ||
"@types/benchmark": "^2.1.0", | ||
"@types/chai": "^4.2.15", | ||
"@types/lodash": "^4.14.168", | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^14.14.27", | ||
"benchmark": "^2.1.4", | ||
"bluebird": "^3.7.2", | ||
"chai": "^4.2.0", | ||
"crypto-js": "^4.0.0", | ||
"lodash": "^4.17.20", | ||
"mocha": "^8.1.1", | ||
"tslib": "^2.0.1", | ||
"typescript": "^3.9.7" | ||
"chai": "^4.3.0", | ||
"mocha": "^8.3.0", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
10
182789