开发者

crypto++ / pycrypto with google app engine

开发者 https://www.devze.com 2022-12-29 09:48 出处:网络
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:

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']}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号