0

How can I decode a base64 string in Node.js that was encoded in PHP like:

base64_encode(openssl_encrypt ('password', "AES-256-CBC",  'keyforthepassword',  OPENSSL_RAW_DATA, '6114'))

6114 is an ID of a person.

To decode this in PHP, I would run:

openssl_decrypt(base64_decode ('encoded_password'), "AES-256-CBC", 'keyforthepassword', OPENSSL_RAW_DATA, '6114')

How can I do the above decrypting in Node.js?

Mathew
  • 11
  • 5
  • 2
    Possible duplicate of [How to do Base64 encoding in node.js?](https://stackoverflow.com/questions/6182315/how-to-do-base64-encoding-in-node-js) – Prafulla Kumar Sahu Aug 14 '18 at 14:17
  • Check out the [Base64 encodings and decodings](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding) document from Mozilla. – node_modules Aug 14 '18 at 14:18
  • Do you just need the base 64-decoded string, or do you also want to decrypt the password? – iainn Aug 14 '18 at 14:29
  • I need the decoded format. The password the user entered is what i need. – Mathew Aug 14 '18 at 14:36

1 Answers1

0
var string=<get your string here>;
new Buffer(string,'base64').toString('ascii');
node_modules
  • 4,790
  • 6
  • 21
  • 37
in need of help
  • 1,606
  • 14
  • 27