The next-generation blog, news, and article for you to start sharing your stories today!
Although node js provide a strong crypto library on top of the layer. But still we look for a simple md5 and hash for our application.
So here is simple i line code for generate md5 and hash in nodejs
// your node js file
const crypto = require('crypto');
md5 (string = null ) {
return crypto.createHash('md5').update(string).digest('hex');
}
// md5 function will return md5 hash for given string
// your node js file
const crypto = require('crypto');
hash (string = null) {
return crypto.createHash('sha256').update(string).digest('hex');
}
// hash function will return hash for given string
Thank you for reading.
Vikram Parihar is an senior software engineer. He is working since 2013 in web development technologies. He works in NodeJS, Angular, Vue, PHP, Laravel, Express JS and various popular technologies.