Languages
[Edit]
EN

Node.js - encode text to md5

3 points
Created by:
Dirask JS Member
3460

In this article, we would like to show how to encode text to md5 in Node.js.

1. Using Node.js built-in module - Crypto

const crypto = require('crypto');

const data = 'dirask';
const md5Data = crypto.createHash('md5').update(data).digest('hex');

console.log(md5Data); // 47b3201569d2797c6e0432b71e3bb9e0

2. Using external library - md5 

Install md5 module using npm:

npm install md5

Usage: 

const md5 = require('md5');

const data = 'dirask'
console.log(md5(data)); // 47b3201569d2797c6e0432b71e3bb9e0

Resources

  1. MD5 - Wikipedia 

Node.js - crypto module

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join