Advertisement
Udelunar

Untitled

Apr 12th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function encryptMessage(messagePlain) {
  2.     console.log("-----------------------")
  3.     console.log("---- EncryptMessage ---")
  4.     console.log("-----------------------")
  5.  
  6.     try {
  7.         var key = CryptoJS.enc.Hex.parse(AESKey);
  8.         var ivPlain = "987654321098765"  // generate IV
  9.         var ivHex = CryptoJS.enc.Base64.parse(ivPlain);
  10.         var txtBase64 = new Buffer(messagePlain).toString('base64')    // ENCODE BASE 64 TEXT
  11.         var encrypted = CryptoJS.AES.encrypt(txtBase64, key , { iv: ivHex });      
  12.         encrypted.toString(CryptoJS.enc.base64)
  13.  
  14.         var request = require("request");
  15.  
  16.         var url = 'http://192.168.1.38/info?'+encrypted.toString()+'&'+ivPlain
  17.         console.log("url ",url)
  18.  
  19.         request(url, function (error, response, body) {
  20.             console.log("Finish GET ")
  21.  
  22.         })
  23.     }catch(error) {
  24.         console.log("error ENCRYPT: "+error)
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement