How to hash an email in hex

If you hash a string, you'll get the same output from an input, but it'll be impossible to revert the output. That means, it's a robust way to store sensitive information on a database.

In Node, you can hash a string as follows:

javascript
import crypto from 'crypto';

let string = 'Erik is an engineer from Barcelona';
let hash   = crypto.createHash('md5').udpate(string).digest('hex');

console.log(hash);
// 6354cee04de82ff04aa1a383db4ed64e

Thanks to kitek.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.