logo

The next-generation blog, news, and article for you to start sharing your stories today!

Nodejs md5 generate

Node JS md5 generate.

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

Node JS md5

// 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
    

 

Node JS Hash

// 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.

avatar

Vikram Parihar

An editor at Keyscript

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.