Node.js hash string

hashnode.js

I have a string that I want to hash. What's the easiest way to generate the hash in node.js?

The hash is for versioning, not security.

Best Solution

If you just want to md5 hash a simple string I found this works for me.

var crypto = require('crypto');
var name = 'braitsch';
var hash = crypto.createHash('md5').update(name).digest('hex');
console.log(hash); // 9b74c9897bac770ffc029102a200c5de