2

I would like to encrypt the data transferred between GAE app and my android application (https will not help since the key should be dynamic). I am thinking about AES (128-bit) encryption.

I've tried to use pycrypto (GAE SDK 1.8.6, python 2.7, OS X 10.9):

libraries:
- name: pycrypto
  version: "2.6"

But when I import Crypto it can not find the module:

ImportError: No module named Crypto

Is there any other built-in module I can use? Or, is there any way to be able to use pycrypto (should I install it manually)?

LA_
  • 19,823
  • 58
  • 172
  • 308
  • I had a similar problem, here is how I solved it: http://stackoverflow.com/questions/29350204/app-engine-importerror-no-module-named-crypto-hash/29354265#29354265 – JackNova Mar 30 '15 at 19:10

2 Answers2

1

This happens to be an App Engine supplied module, as detailed here:

https://developers.google.com/appengine/docs/python/tools/libraries27

The Python 2.7 runtime includes some third-party modules. Some of these are available by default; others are only available if configured. You can specify which version you want to use. https://developers.google.com/appengine/docs/python/python25/migrate27#Configuring_Libraries

To enable included libraries edit your app.yaml like this:

libraries:
- name: pycrypto
  version: latest

In general you'd need to add the files themselves to the same directory that app.yaml is in, as per this question: Uploading Python third party libraries but this happens to be a supplied library.

Community
  • 1
  • 1
Paul Collingwood
  • 9,053
  • 3
  • 23
  • 36
  • Thanks, Paul. I replaced version `2.6` with `latest` (what you recommend), but it didn't help - still Crypto is not found. – LA_ Oct 27 '13 at 17:33
  • I can get "from Crypto.PublicKey import RSA" to work on the playground. Have a look. https://cloud-playground.appspot.com/playground/p/6423617780842496/#main.py – Paul Collingwood Oct 27 '13 at 18:18
  • hmm, further to that last comment it throws no error even without that line in the app.yaml. dunno for now. – Paul Collingwood Oct 27 '13 at 18:40
  • are you experiencing error in server or localhost? in localhost you need to install pycrypto manually, in appengine server you only need to specify it in the yaml file – marcadian Oct 28 '13 at 05:13
  • lol, yes, there should be a new tag I think for the local dev_server related questions. This is no doubt it. – Paul Collingwood Oct 28 '13 at 08:47
  • @marcadian, yes, I am talking about dev_server (i.e. localhost). – LA_ Oct 28 '13 at 17:30
0

Last time I used easy_install to install pycrypto, it's not working (old gae version though) so I did this: - download pycrypto - extract, cd to the pycrypto folder - python setup.py build - sudo python setup.py install

marcadian
  • 2,608
  • 13
  • 20