SHARE
TWEET

Untitled

a guest Jul 19th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function testFunc(){
  2.         var secretKey = '2B7E151628AED2A6ABF7158809CF4F3C';
  3.         iv = "GaBeUBJepgDHXI+3fKWZMg==";
  4.         var message = {
  5.             "action":"switch"
  6.         };
  7.         message = JSON.stringify(message);
  8.        
  9.         iv = new Buffer( iv , 'base64').toString('hex');
  10.        
  11.         iv = CryptoJS.enc.Hex.parse( iv );
  12.         let key= CryptoJS.enc.Hex.parse( secretKey );
  13.         console.log("Let's ");
  14.             // Decrypt
  15.            
  16.         var bytes  = CryptoJS.AES.decrypt( message, key , { iv: iv} );
  17.         var plaintext = bytes.toString(CryptoJS.enc.Base64);
  18.         var decoded_b64msg =  new Buffer(plaintext , 'base64').toString('ascii');
  19.         var encoded_msg =     new Buffer( bytes).toString('base64');
  20.         console.log("Encoded Message: ", encoded_msg);
  21.         // console.log("Decryptedage UTF8 decoded: ", plaintext);
  22.         return {payload:encoded_msg};
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top