Skip to content
Advertisement

How to convert PHP MD5 in NodeJS

I couldn’t find a concrete example for my problem

I need to convert this line PHP in NodeJS :

if (md5($value1.$value2.$value3.$value4.$value5) != $value)

I have used several things without success, like CryptoJS.HmacMD5, CryptoJS.MD5 or md5

I feel it’s a bit more complex with NodeJS, the values ​​correspond to queries in the url that I retrieve with express, req.query.value_1

Advertisement

Answer

This should work

const crypto = require('crypto');

const data = "value";
const hash = crypto.createHash('md5').update(data).digest("hex");

if (hash != "value") { }

PS: you don’t need to install it as it already comes with Node

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement