From 7bbe288d9c8834989988cd0a49603e4bec2e9399 Mon Sep 17 00:00:00 2001 From: Jacob Alheid Date: Fri, 11 Feb 2022 12:32:12 -0800 Subject: [PATCH] fix: use sha instead of deprecated md5 for hash algorithm (#868) * fix: use sha instead of deprecated md5 for hash algorithm * fix: use sha256 instead of md4/5 --- src/cli.js | 2 +- src/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cli.js b/src/cli.js index 0cc5f4fd..eeeaebb7 100755 --- a/src/cli.js +++ b/src/cli.js @@ -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); diff --git a/src/index.js b/src/index.js index 755ad1d5..1cb6c5fe 100644 --- a/src/index.js +++ b/src/index.js @@ -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); @@ -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