Skip to content

Commit

Permalink
fix: use sha instead of deprecated md5 for hash algorithm (#868)
Browse files Browse the repository at this point in the history
* fix: use sha instead of deprecated md5 for hash algorithm

* fix: use sha256 instead of md4/5
  • Loading branch information
shakefu authored Feb 11, 2022
1 parent 5fc63b8 commit 7bbe288
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async function runCmd (argv, stdout, stderr) {

outDir = resolve(
require("os").tmpdir(),
crypto.createHash('md5').update(resolve(args._[1] || ".")).digest('hex')
crypto.createHash('sha256').update(resolve(args._[1] || ".")).digest('hex')
);
if (existsSync(outDir))
rimraf.sync(outDir);
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SUPPORTED_EXTENSIONS = [".js", ".json", ".node", ".mjs", ".ts", ".tsx"];

const hashOf = name => {
return crypto
.createHash("md4")
.createHash("sha256")
.update(name)
.digest("hex")
.slice(0, 10);
Expand Down Expand Up @@ -174,13 +174,13 @@ function ncc (
function get(key) {
if (aliasMap.has(key)) return aliasMap.get(key);
if (regexCache.has(key)) return regexCache.get(key);

for (const regex of regexps) {
const matches = key.match(regex)

if (matches) {
let result = aliasMap.get(regex)

if (matches.length > 1) {
// allow using match from regex in result
// e.g. caniuse-lite(/.*) -> caniuse-lite$1
Expand Down

0 comments on commit 7bbe288

Please sign in to comment.