如何在GAP中使用pycrypto?
这里链接说它不支持最新版本。这是否意味着我必须使用他们指定的版本?
我尝试了这个,但是当我执行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
如何在GAP中使用pycrypto?
这里链接说它不支持最新版本。这是否意味着我必须使用他们指定的版本?
我尝试了这个,但是当我执行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
刚发布的App Engine 1.7.2现在支持最新版本的PyCrypto 2.6。链接文档可能已过时,将很快得到更新。您可以通过指示应用程序引擎包含它来使用它。
libraries:
- name: pycrypto
version: "2.6"
如虎添翼,像使用魔法一样,编写代码
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 )
应该能够完美运行(实际上会触发下载!)
GAP不允许您使用完整版本的pycrypto,因为它有很多C代码,所以您无法部署它,他们必须将其缩减到可以允许的范围内。您必须使用from google.appengine.dist import use_library
,然后使用use_library('lib', 'version.')
。希望这对您有所帮助。