加密++ / pycrypto与谷歌应用程序引擎 [英] crypto++ / pycrypto with google app engine

查看:148
本文介绍了加密++ / pycrypto与谷歌应用程序引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用crypto ++将AES加密的http请求发送给应用引擎,计划在那里解密它们。我的计划是在'?'之后加密部分,所以它是这样的:



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆