Skip to content

Commit

Permalink
fix: use sha.js instead of crypto for hash calculation (#5270)
Browse files Browse the repository at this point in the history
* Use sha.js instead of crypto for hash calculation

* proper use of shajs library

Co-authored-by: Kononnable <kononnable@gmail.com>
  • Loading branch information
2 people authored and pleerock committed Jan 2, 2020
1 parent 39057ca commit b380a7f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
60 changes: 47 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@types/mocha": "^5.2.6",
"@types/node": "^9.6.0",
"@types/rimraf": "^2.0.2",
"@types/sha.js": "^2.4.0",
"@types/sinon": "^7.0.8",
"@types/source-map-support": "^0.4.2",
"@types/yargs": "^12.0.9",
Expand Down Expand Up @@ -105,6 +106,7 @@
"js-yaml": "^3.13.1",
"mkdirp": "^0.5.1",
"reflect-metadata": "^0.1.13",
"sha.js": "^2.4.11",
"tslib": "^1.9.0",
"xml2js": "^0.4.17",
"yargonaut": "^1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/util/StringUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as crypto from "crypto";
import * as shajs from "sha.js";

/**
* Converts string into camelCase.
Expand Down Expand Up @@ -102,7 +102,7 @@ interface IHashOptions {
* @param options.length Optionally, shorten the output to desired length.
*/
export function hash(input: string, options: IHashOptions = {}): string {
const hashFunction = crypto.createHash("sha256");
const hashFunction = shajs("sha256");

hashFunction.update(input, "utf8");

Expand Down

0 comments on commit b380a7f

Please sign in to comment.