Skip to content

Commit 19fb463

Browse files
committed
Use MD4 instead of SHA1 for filename hashes
We don't need the cryptographic strength of SHA-1 for this purpose, so we may as well use a faster hashing algorithm. While I was at it, I also sapped out the use of hash.end + hash.read combo for the faster and more conventional hash.update + hash.digest. In my local testing, this also seems to offer a nice speed boost.
1 parent 8544ffa commit 19fb463

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/fs-cache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ const write = function(filename, result, callback) {
7171
* @return {String}
7272
*/
7373
const filename = function(source, identifier, options) {
74-
const hash = crypto.createHash("SHA1");
74+
const hash = crypto.createHash("md4");
7575
const contents = JSON.stringify({
7676
source: source,
7777
options: options,
7878
identifier: identifier,
7979
});
8080

81-
hash.end(contents);
81+
hash.update(contents);
8282

83-
return hash.read().toString("hex") + ".json.gz";
83+
return hash.digest("hex") + ".json.gz";
8484
};
8585

8686
/**

0 commit comments

Comments
 (0)