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

Use MD4 instead of SHA1 for filename hashes #639

Merged
merged 1 commit into from
Jul 5, 2018
Merged
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
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.
  • Loading branch information
lencioni committed Jul 5, 2018
commit bad8acc799613f3ffa3aa7cb5df99d252b7b8966
6 changes: 3 additions & 3 deletions src/cache.js
Original file line number Diff line number Diff line change
@@ -62,13 +62,13 @@ const write = async function(filename, result) {
* @return {String}
*/
const filename = function(source, identifier, options) {
const hash = crypto.createHash("SHA1");
const hash = crypto.createHash("md4");

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

hash.end(contents);
hash.update(contents);

return hash.read().toString("hex") + ".json.gz";
return hash.digest("hex") + ".json.gz";
};

/**