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

fix: use sha instead of deprecated md5 for hash algorithm #868

Merged
merged 2 commits into from
Feb 11, 2022
Merged
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
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