Node JS MD5 + Base64
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I need some code to be able to encrypt this string using MD5 and then convert it to base 64: <order></order>123456 in Node JS

The end result should be this: LghTkEmsD2tbQ3fsIBRcBg==

The PHP equivalent is this: base64_encode(hex2bin(md5('<order></order>123456')))

Just to let you know, md5 is a hashing algorithm, not encryption. So if you would like to decrypt it after that, I believe it's not possible.
Chlegou over 1 year ago
I just need a way to transform this <order></order>123456 into this LghTkEmsD2tbQ3fsIBRcBg== in Node JS. The third party documentation only has a PHP method like this but no Node JS documentation base64_encode(hex2bin(md5('<order></order>123456')))
user0809 over 1 year ago
awarded to TheOsch

Crowdsource coding tasks.

1 Solution

Winning solution

const crypto = require("crypto");


It's the first variant. Here is the second one (a fix of B44ken's solution):

const md5 = require("md5");
const encodeHash = msg => Buffer.from(md5(msg), "hex").toString("base64");

Choose whatever you like.

View Timeline