javascript - How to decrypt a field sent from client to Node server using CryptoJS? -


i trying adapt following solution node application decrypt field sent client browser via post:

how decrypt cryptojs using aes?

seem going round in circles in getting values match in console. values encryption of 'hello' match both applied server , client (sending 'hello' there no decryption value showing either.

the server side code in node post route:

var enc_key = "c2vjcmv0"; //'secret' app.post('/hello', function (req, res) {     console.log('post /hello');      var key = cryptojs.enc.base64.parse(enc_key);      console.log('key: ' + key);       console.log('client msg ("hello"): ' + req.body.msg_hello);      var encrypted = cryptojs.aes.encrypt("hello", key, {         mode: cryptojs.mode.ecb,         padding: cryptojs.pad.pkcs7     });      console.log('server msg "hello" encrypted to: ' + encrypted);      var decrypted = cryptojs.aes.decrypt(encrypted, key, {         mode: cryptojs.mode.ecb,         padding: cryptojs.pad.pkcs7     });      console.log('server msg decrypted: ' + hex2a(decrypted));      var decryptedclient = cryptojs.aes.decrypt(req.body.msg_hello, key, {         mode: cryptojs.mode.ecb,         padding: cryptojs.pad.pkcs7     });        console.log('client msg decrypted: ' + hex2a(decryptedclient));      res.end(json.stringify('{ response: "response" }')); }); 

any appreciated!


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -