Problems With AES In Crypto-js And Pycrypto
I try to implement a communication between crypto-js (a javascript crypto library) and pycrypto (a python crypto library) On the python server side I encrypt a string with an iv
Solution 1:
Before You encode to base64 You must sum iv and encrypted_text:
encrypted_text = base64.b64encode(iv + aes.encrypt("this is a test.."))
From the official documentation (https://www.dlitz.net/software/pycrypto/doc/) :
As an example, encryption can be done as follows:
from Crypto.Cipher import AES
from Crypto import Random
key = b'Sixteen byte key'
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
msg = iv + cipher.encrypt(b'Attack at dawn')
Post a Comment for "Problems With AES In Crypto-js And Pycrypto"