Skip to content

Commit 4bb9e21

Browse files
authored
Use md5 hashing for OpenSSL 3 (#924)
1 parent 247c94b commit 4bb9e21

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/cache.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ const transform = require("./transform");
1919
// Lazily instantiated when needed
2020
let defaultCacheDirectory = null;
2121

22+
let hashType = "md4";
23+
// use md5 hashing if md4 is not available
24+
try {
25+
crypto.createHash(hashType);
26+
} catch (err) {
27+
hashType = "md5";
28+
}
29+
2230
const readFile = promisify(fs.readFile);
2331
const writeFile = promisify(fs.writeFile);
2432
const gunzip = promisify(zlib.gunzip);
@@ -63,13 +71,6 @@ const write = async function (filename, compress, result) {
6371
* @return {String}
6472
*/
6573
const filename = function (source, identifier, options) {
66-
// md4 hashing is not supported starting with node v17.0.0
67-
const majorNodeVersion = parseInt(process.versions.node.split(".")[0], 10);
68-
let hashType = "md4";
69-
if (majorNodeVersion >= 17) {
70-
hashType = "md5";
71-
}
72-
7374
const hash = crypto.createHash(hashType);
7475

7576
const contents = JSON.stringify({ source, options, identifier });

0 commit comments

Comments
 (0)