@appolo/utils
Advanced tools
Comparing version 8.0.18 to 8.0.19
import {Strings} from '../strings'; | ||
import {BinaryLike, createHash, BinaryToTextEncoding} from "crypto"; | ||
import {BinaryLike, createHash} from "crypto"; | ||
export class Hash { | ||
public static hash(value: BinaryLike, algorithm: string = 'sha1', encoding: BinaryToTextEncoding = 'hex'): string { | ||
public static hash(value: BinaryLike, algorithm: string = 'sha1', encoding: 'base64' | 'hex' = 'hex'): string { | ||
return createHash(algorithm).update(value).digest(encoding); | ||
} | ||
public static hashPlainObject(obj: { [index: string]: string | number | boolean }, algorithm: string = 'sha1', encoding: BinaryToTextEncoding = 'hex'): string { | ||
public static hashPlainObject(obj: { [index: string]: string | number | boolean }, algorithm: string = 'sha1', encoding: 'base64' | 'hex' = 'hex'): string { | ||
return Hash.hash(Strings.stringifyObjectValues(obj),algorithm,encoding); | ||
@@ -13,0 +13,0 @@ } |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.18", | ||
"version": "8.0.19", | ||
"license": "MIT", | ||
@@ -34,12 +34,12 @@ "repository": { | ||
"@types/benchmark": "^2.1.0", | ||
"@types/chai": "^4.2.15", | ||
"@types/chai": "^4.2.16", | ||
"@types/lodash": "^4.14.168", | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^14.14.27", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.37", | ||
"benchmark": "^2.1.4", | ||
"chai": "^4.3.0", | ||
"mocha": "^8.3.0", | ||
"chai": "^4.3.4", | ||
"mocha": "^8.3.2", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.5" | ||
"typescript": "^4.2.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
188128