【问题标题】:pycrypto and Google app enginepycrypto 和谷歌应用引擎
【发布时间】:2012-09-20 00:01:59
【问题描述】:

你如何在 GAP 中使用 pycrypto?

它说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

【问题讨论】:

  • 或许您应该使用正确的标签 google-app-engine 而不是 google-apps-script 来获得答案?

标签: python google-app-engine libraries pycrypto


【解决方案1】:

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

【讨论】:

  • 我添加了 pycrypto 版本 2.6 。当我在本地运行它时它可以工作,当我部署它时它在访问该站点时给我一个服务器错误。
  • @mjibson 这无关紧要,只是服务器 500 错误。没有其他信息。无论如何,我设法解决了这个问题。我仍然在一个文件中包含另一个库passlib,这给出了错误。
【解决方案2】:

要让 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

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      相关资源
      最近更新 更多