I'm trying to decode data which is generated from this JavaScript code: jeTV: (t, e, r) => { "use strict"; r.d(e, { X: () => s }); var n = r("wIp5") , i = r.n(n) , s = (r("4Whi"), function(t, e) { var r = i().lib.WordArray.random(12).toString(i().enc.Base64) , n = i().AES.encrypt(t, i().enc.Utf8.parse(e), { iv: i().enc.Utf8.parse(r) }); return "".concat(r).concat(n.ciphertext.toString(i().enc.Base64)) } ) } My code: def decrypt(encrypted_data, key): # Extract the Base64 IV and ciphertext iv_base64 = encrypted_data[:16] # First 16 characters (Base64-encoded IV) ciphertext_base64 = encrypted_data[16:] # The rest is the ciphertext # Use the Base64 string directly as IV, without decoding it back to bytes iv_bytes = iv_base64[:16].encode('utf-8') # Get the first 16 chars of the Base64-encoded IV # Decode the ciphertext ciphertext = base64_decode(ciphertext_base64) # Create AES cipher object for decryption cipher = AES.new(key.encode('utf-8'), AES.MODE_CBC, iv_bytes) # Decrypt and unpad the plaintext plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size) return plaintext.decode('utf-8') But I got this error when run the program: plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D\venv\Lib\site-packages\Crypto\Util\Padding.py", line 95, in unpad raise ValueError("PKCS#7 padding is incorrect.") ValueError: PKCS#7 padding is incorrect. I checked the key and the Base64-decoded IV/ciphertext, and they seem to match what was generated during encryption. I printed the raw decrypted bytes, but I’m not sure if they are binary data or not. Any insights or suggestions on how to resolve this issue would be appreciated. Continue reading...