coredump
coredump

Reputation: 3117

pycrypto and Google app engine

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

Upvotes: 3

Views: 3180

Answers (3)

bobobobo
bobobobo

Reputation: 67376

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

Upvotes: 3

maddyblue
maddyblue

Reputation: 16882

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.

Upvotes: 4

root
root

Reputation: 80456

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.

Upvotes: 0

Related Questions