问题
How do you use pycrypto with GAP?
It says here that it does not support the latest version. Does that mean that I have to use the version pointed by them ?
I tried this but, when I execute setup.py
I get the error src/MD2.c:15:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
回答1:
App Engine 1.7.2, released just a few hours ago, now supports PyCrypto 2.6, the most recent version. The linked doc is likely outdated and will be updated soon. You can use it by instructing app engine to include it.
回答2:
To make GAE use pycrypto, you have to add the following to your app.yaml file:
libraries:
- name: pycrypto
version: "2.6"
Like a charm, 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 )
Should work like a charm (actually triggers a download!)
This information about what versions of what libraries are available are included here
回答3:
GAP will not let you use the full version of pycrypto as it has lot of C so you can't deploy it and they will have to cut it down to what they can allow. You have to use from google.appengine.dist import use_library
and then use_library('lib', 'version.')
. Hopefully it is somewhat helpful.
来源:https://stackoverflow.com/questions/12504489/pycrypto-and-google-app-engine