I am trying to decrypt a string encoded with "crypto-js" and decode it in python using "pyCrypto". I have followed the exact steps on various blogs but still the same error.
Last stackoverflow post i followed was "CryptoJS and Pycrypto working together" the answer given by @Artjom B.
Also tried "https://chase-seibert.github.io/blog/2016/01/29/cryptojs-pycrypto-ios-aes256.html"
My js code is
var pass = CryptoJS.AES.encrypt(text, password_encrypt_key,
{
iv: password_encrypt_iv,
})
return password_encrypt_iv.concat(pass.ciphertext).toString(CryptoJS.enc.Base64);
And my python code is
BLOCK_SIZE = 16
KEY = constants.PASSWORD_ENCRYPT_KEY
# IV = constants.PASSWORD_ENCRYPT_IV
IV = enc_password[:BLOCK_SIZE]
MODE = AES.MODE_CBC
enc_password = base64.b64decode(enc_password)
aes = AES.new(KEY, MODE, IV)
password = unpad(aes.decrypt(enc_password[BLOCK_SIZE:]))
unpad function
def unpad(s):
return s[:-ord(s[-1])]