Skip to content

Instantly share code, notes, and snippets.

@keepitsimple
Created June 18, 2021 16:48
Show Gist options
  • Save keepitsimple/d36e9c13c6610c0e394303543aa87e1e to your computer and use it in GitHub Desktop.
Save keepitsimple/d36e9c13c6610c0e394303543aa87e1e to your computer and use it in GitHub Desktop.
Node.js fastest hash function
const crypto = require('crypto');
console.time('hash')
const hash = crypto.createHash('md5').update(str).digest("hex");
console.timeEnd('hash')
console.log(hash)
// sha1 function is much faster on my computer
console.time('hash2')
const hash2 = crypto.createHash('sha1').update(str).digest("base64");
console.timeEnd('hash2')
console.log(hash2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment