Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8161261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:27:41+00:00 2026-06-06T18:27:41+00:00

I have a function which encrypts a string with AES using PyCrypto. When I

  • 0

I have a function which encrypts a string with AES using PyCrypto. When I call that function in my unit tests, everything works fine. On the production environment, it works fine as well. However, when the function is called on the GAE development server, an error is thrown: “ImportError: cannot import name blockalgo”. I tested it on Windows 7 (64 bit) and Mac OS 10.5. Both resulted in the same error. I’m using Google App Engine with Python 2.7. What could be the problem?

app.yaml

application: xxx
version: 6
runtime: python27
api_version: 1
threadsafe: true

libraries:
- name: django
  version: "1.2"
- name: webapp2
  version: "2.3"
- name: jinja2
  version: "2.6"
- name: pycrypto
  version: "2.3"
- name: PIL
  version: "1.1.7"

builtins:
- appstats: on
- remote_api: on

inbound_services:
- mail
- warmup

Encryption function:

def encrypt(plaintext):
    from Crypto.Cipher import AES
    import hashlib

    password = 'xxx'
    key = hashlib.sha256(password).digest()

    mode = AES.MODE_ECB
    encryptor = AES.new(key, mode)

    BLOCK_SIZE = 16
    PADDING = '{'
    pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
    EncodeAES = lambda c, s: b58encode(c.encrypt(pad(s)))

    encrypted = EncodeAES(encryptor, plaintext)

    if len(encrypted) < 22:
        for i in range (len(encrypted), 22):
            encrypted += "_"
    return encrypted
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:27:42+00:00Added an answer on June 6, 2026 at 6:27 pm

    Make sure the version of PyCrypto that is installed on your local system is the same as the version specified in app.yaml. Think twice before you upgrade a package to the newest version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to encrypt a string using MySQL's AES_ENCRYPT function, then attach that encrypted
I have a function that encrypts and upload a file from my system to
I have this PHP function (using PHP 5.3) that I use to decrypt files,
I have function getMemory() which returns VARIANT (mfc). It is said that in ulVal
hi i have function which is called by tinker listbox so i cannot return
Can I´m asking for advice. I have function which should return javascript object function
I have a function which looks something like this, it returns a noncopyable class
I have a function which I have to loop it a few times but
I have a function which takes two arguments, the ID of an item (wine)
I have a function which takes several boolean template arguments: template<bool par1, bool par2,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.