I have some JSON data that I need to encrypt before sending it to the client side. I can encrypt the data using pycrpto like this:
from Crypto.Cipher import AES
key = '0123456789abcdef'
mode = AES.MODE_CBC
encryptor = AES.new(key, mode)
text = jsonData
ciphertext = encryptor.encrypt(text)
And then I can send it to the client side. Now I need to use jQuery/Javascript to convert the ciphertext to plain text. jsaes is an implementation of AES in Javascript. Can it be used to decrypt data back to plain text? Or is there any other library I can use to complete this task?
You should be able to decrypt it using any implementation of AES, just make sure you use the same
modethat you used to encrypt it (in this case Cipher Block Chain or CBC)http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
Also PyCrypto, while good, might be a little bit too low level for you. You might want to look at using something like GPGME for Python: http://pyme.sourceforge.net/