0

I am trying to encrypt in javascript using cryptoJS and decrypt in python but some how I am unable to get this working.Here is my code :

//encrypting in javascript using cryptojs
var message = "praveen";
var key = 'This is a key123';
var iv = 'This is an IV456';

var encrypted = CryptoJS.AES.encrypt(message, key, {
  iv: CryptoJS.enc.Utf8.parse(iv),
  mode: CryptoJS.mode.CFB,
  padding: CryptoJS.pad.ZeroPadding
});

console.log(encrypted.ciphertext.toString()); // sending this over wire
#decrypting in python

BLOCK_SIZE = 16
SEGMENT_SIZE = 128

def aes_decrypt(plaintext):
    key = 'This is a key123'
    iv = 'This is an IV456' 
    aes_mode = AES.MODE_CFB
    obj = AES.new(key, aes_mode, iv)
    ciphertext = obj.decrypt(plaintext)
    ciphertext = _unpad_string(ciphertext)
    return ciphertext
adiga
  • 34,372
  • 9
  • 61
  • 83

0 Answers0