2012-09-20 115 views
3

你如何使用pycrypto和GAP?pycrypto和Google应用引擎

它说here它不支持最新版本。这是否意味着我必须使用他们指出的版本?

我试过,但,当我执行setup.py我得到的错误src/MD2.c:15:20: fatal error: Python.h: No such file or directory compilation terminated.
error: command 'gcc' failed with exit status 1

+0

大概你shoul d使用正确的标签谷歌应用程序引擎,而不是谷歌应用程序脚本得到答案? – Taifun

回答

3

几个小时前发布的App Engine 1.7.2现在支持最新版本的PyCrypto 2.6。链接的文档很可能已过时,并会很快更新。你可以使用instructing app engine to include it

+0

我添加了pycrypto版本2.6。当我运行本地它的工作,当我部署它给我一个访问该网站时出现服务器错误。 – coredump

+0

你能显示错误的全文吗? – mjibson

+0

@mjibson这没什么关系,只是一个服务器500错误。没有其他信息。无论如何,我设法解决了这个问题。我仍然在文件中包含另一个库'passlib',因为这是错误。 – coredump

0

GAP不会让你使用完整版本pycrypto的,因为它有很多的C,所以你不能部署,他们将有把它削减到他们可以允许的程度。您必须使用from google.appengine.dist import use_library,然后使用use_library('lib', 'version.')。希望这有些帮助。

3

为了GAE使用pycrypto,您必须将以下添加到您的app.yaml文件:

libraries: 
- name: pycrypto 
    version: "2.6" 

就像一个魅力,code like

from Crypto.Cipher import AES 
from Crypto import Random 
class MainPage(webapp2.RequestHandler): 
    def get(self) : 
    self.response.headers['Content-Type'] = 'text/plain' 
    key = b'Sixteen byte key' 
    iv = Random.new().read(AES.block_size) 
    cipher = AES.new(key, AES.MODE_CFB, iv) 
    msg = iv + cipher.encrypt(b'Attack at dawn') 
    self.response.write(msg) 

应该像一个魅力(实际上触发器一个下载!)

This information about what versions of what libraries are available are included here