Generating a MD5 hash in NodeJS

A few days ago I wanted to integrate gravatar in one of the applications I’v been working on, and realized gravatar still uses MD5 for hashing the user’s email.

I was wondering whether I would need an external module to generate the hash, but quickly realized the native crypto can do the trick:

const crypto = require('crypto')

let hash = crypto.createHash('md5').update('some_string').digest("hex")

It really doesn’t get any easier than that — adios!

Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 150+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $6.99

In the mood for some more reading?

...or check the archives.