Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace crypto dependencies with node internals #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
"src/**"
]
},
"dependencies": {
"js-md5": "^0.7.3",
"js-sha1": "^0.6.0"
},
"devDependencies": {
"eslint": "^8.23.0",
"jest": "^27.0.1"
Expand Down
7 changes: 3 additions & 4 deletions src/lib.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var md5 = require('js-md5');
var sha1 = require('js-sha1');
var crypto = require('node:crypto');

/** List of hex digit for fast accessing by index */
var HEX_DIGITS = '0123456789abcdef'.split('');
Expand Down Expand Up @@ -72,7 +71,7 @@ var stringToCharBuffer = function (str) {
* @returns {Uint8Array} MD5 hash buffer
*/
var md5Hash = function (buf) {
return new Uint8Array(md5.arrayBuffer(buf));
return new Uint8Array(crypto.createHash('md5').update(buf).digest());
};

/**
Expand All @@ -81,7 +80,7 @@ var md5Hash = function (buf) {
* @returns {Uint8Array} SHA-1 hash buffer
*/
var sha1Hash = function (buf) {
return new Uint8Array(sha1.arrayBuffer(buf));
return new Uint8Array(crypto.createHash('sha1').update(buf).digest());
};

/**
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2063,16 +2063,6 @@ jest@^27.0.1:
import-local "^3.0.2"
jest-cli "^27.5.1"

js-md5@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/js-md5/-/js-md5-0.7.3.tgz#b4f2fbb0b327455f598d6727e38ec272cd09c3f2"
integrity sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==

js-sha1@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/js-sha1/-/js-sha1-0.6.0.tgz#adbee10f0e8e18aa07cdea807cf08e9183dbc7f9"
integrity sha512-01gwBFreYydzmU9BmZxpVk6svJJHrVxEN3IOiGl6VO93bVKYETJ0sIth6DASI6mIFdt7NmfX9UiByRzsYHGU9w==

js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
Expand Down