Skip to main content
 首页 » 编程设计

python之如何将 AES 与 GAE python 一起使用

2025年05月04日9birdshome

我想加密 GAE 应用程序和我的 android 应用程序之间传输的数据(https 无济于事,因为 key 应该是动态的)。我正在考虑 AES(128 位)加密。

我尝试使用 pycrypto(GAE SDK 1.8.6、python 2.7、OS X 10.9):

libraries: 
- name: pycrypto 
  version: "2.6" 

但是当我import Crypto时它找不到模块:

ImportError: No module named Crypto 

我可以使用任何其他内置模块吗?或者,有什么方法可以使用 pycrypto(我应该手动安装它)吗?

请您参考如下方法:

这恰好是 App Engine 提供的模块,详情如下:

https://developers.google.com/appengine/docs/python/tools/libraries27

The Python 2.7 runtime includes some third-party modules. Some of these are available by default; others are only available if configured. You can specify which version you want to use. https://developers.google.com/appengine/docs/python/python25/migrate27#Configuring_Libraries

要启用包含的库,请像这样编辑您的 app.yaml:

libraries: 
- name: pycrypto 
  version: latest 

一般来说,您需要将文件本身添加到 app.yaml 所在的同一目录,根据这个问题:Uploading Python third party libraries但这恰好是一个提供的库。