加密++ / pycrypto与谷歌应用程序引擎 [英] crypto++ / pycrypto with google app engine
问题描述
http://myurl.com/Command?eiwjfsdlfjldkjfs 加密时。但是,我一直在找出如何解密它在另一端,仍然用户get()的响应获得args。有人建议我是否采取错误的做法?我应该解密而不是使用get(),但是我自己的解析器呢?
我想你应该创建一个这样的URL :
http://myurl.com/Command?q=eiwjfsdlfjldkjfs
/ pre>
然后,在你的请求处理程序中,你可以得到这样的加密消息:
encrypted_string = self.request.get('q')
编辑:
这是如何做到的:
1)创建url:
导入Crypto
从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应该是'myurl.com/Command?q=%D4%2B%E5%FA%04rE %1C。%81%0C%B6t%DC1%F8%84%EB'
2) Ť o解密:
ciph = self.request.get('q')
obj = ARC4.new( 'stackoverflow')
plain = obj.decrypt(ciph)
get_data = cgi.parse_qs(plain)#{'param2':['v2'],'param1':['v1']}
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']}
这篇关于加密++ / pycrypto与谷歌应用程序引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!