crypto++ / pycrypto with google app engine
I am using crypto++ to send AES encrypted http requests to app engine, planning to decrypt them there. My plan is to encrypt the portion after the '?' so it's something like:
http://myurl.com/Command?eiwjfsdlfjldkjfs when it is encrypted. However, I'm stuck figuring out how to decrypt it at the other end and still user get() on the response to get the args. Can someone advise if I am taking the wrong approach? Should I be decrypting and not using开发者_开发技巧 get() but my own parser then?
I think you should create the URL like this:
http://myurl.com/Command?q=eiwjfsdlfjldkjfs
Then, in your request handler, you would be able to get the encrypted message like this:
encrypted_string = self.request.get('q')
EDIT:
This is how to do it:
1) to create the url:
import Crypto
from Crypto.Cipher import ARC4
obj=ARC4.new('stackoverflow')
plain = urllib.urlencode({'param1': 'v1', 'param2': 'v2'})
ciph = obj.encrypt(plain)
url = 'myurl.com/Command?%s' % urllib.urlencode({'q': ciph})
#url should be 'myurl.com/Command?q=%D4%2B%E5%FA%04rE.%1C.%81%0C%B6t%DCl%F8%84%EB'
2) to decrypt it:
ciph = self.request.get('q')
obj=ARC4.new('stackoverflow')
plain = obj.decrypt(ciph)
get_data = cgi.parse_qs(plain) # {'param2': ['v2'], 'param1': ['v1']}
精彩评论