lundi 4 juillet 2016

CryptoJS and Pycrypto Compatibility [duplicate]

This question already has an answer here:

I'm having some issues with CryptoJS talking to PyCrypto via Flask.

I've got the following JS

var encrypted = CryptoJS.AES.encrypt(message, "1234567812345678", {
    iv: iv,
    padding: CryptoJS.pad.Pkcs7
}).toString();

location.href = "/x=" + encodeURIComponent(btoa(iv + encrypted));

and the following Python

iv = x[:16]
query = x[16:]

key = b'1234567812345678'
aes = AES.new(key, AES.MODE_CBC, iv)
message = aes.decrypt(query)

I've tried following this SO post CryptoJS and Pycrypto working together.

I can't get the decypted result to resemble anything near the original message.

I was originally using CFB, but couldn't get that to work, so I switched over to CBC with padding (which doesn't seem to be getting applied, at the ciphertext is 44 characters long).

Aucun commentaire:

Enregistrer un commentaire