Create MD5 hash with Node.js


Given a string:

var string = 'my string';

You can generate an MD5 hash like so:

var crypto = require('crypto');
var hash = crypto.createHash('md5').update(string).digest('hex');
console.log(hash);

As a reminder, you probably don’t want to use the MD5 algorithm for encryption as it can be easily brute-forced.

However, it does serve as a useful checksum to verify data integrity.

Here’s a module that calculates MD5 hashes:



Please support this site and join our Discord!