pycrypto

ImportError: No module named Crypto.Cipher

南楼画角 提交于 2019-11-26 15:25:10
问题 When I try to run app.py (Python 3.3, PyCrypto 2.6) my virtualenv keeps returning the error listed above. My import statement is just from Crypto.Cipher import AES . I looked for duplicates and you might say that there are some, but I tried the solutions (although most are not even solutions) and nothing worked. You can see what the files are like for PyCrypto below: 回答1: I had the same problem (though on Linux). The solution was quite simple - add: libraries: - name: pycrypto version: "2.6"

Python Encrypting with PyCrypto AES

这一生的挚爱 提交于 2019-11-26 13:19:29
问题 I just found pycrypto today, and I've been working on my AES encryption class. Unfortunately it only half-works. self.h.md5 outputs md5 hash in hex format, and is 32byte. This is the output. It seems to decrypt the message, but it puts random characters after decryption, in this case \n\n\n... I think I have a problem with block size of self.data, anyone know how to fix this? Jans-MacBook-Pro:test2 jan$ ../../bin/python3 data.py b'RLfGmn5jf5WTJphnmW0hXG7IaIYcCRpjaTTqwXR6yiJCUytnDib+GQYlFORm

How to decrypt OpenSSL AES-encrypted files in Python?

Deadly 提交于 2019-11-26 12:02:37
OpenSSL provides a popular (but insecure – see below!) command line interface for AES encryption: openssl aes-256-cbc -salt -in filename -out filename.enc Python has support for AES in the shape of the PyCrypto package, but it only provides the tools. How to use Python/PyCrypto to decrypt files that have been encrypted using OpenSSL? Notice This question used to also concern encryption in Python using the same scheme. I have since removed that part to discourage anyone from using it. Do NOT encrypt any more data in this way, because it is NOT secure by today's standards. You should ONLY use

How do I install PyCrypto on Windows?

不羁的心 提交于 2019-11-26 12:00:16
I've read every other google source and SO thread, with nothing working. Python 2.7.3 32bit installed on Windows 7 64bit . Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat". So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error". How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working). Any ideas? Michael Dillon If you

Microsoft Windows Python-3.6 PyCrypto installation error

Deadly 提交于 2019-11-26 10:25:24
问题 pip install pycrypto works fine with python3.5.2 but fails wiht python3.6 with the following error: inttypes.h(26): error C2061: syntax error: identifier \'intmax_t\' 回答1: The file include\pyport.h in Python installation directory does not have #include < stdint.h > anymore. This leaves intmax_t undefined. A workaround for Microsoft VC compiler is to force include stdint.h via OS environment variable CL : Open command prompt Setup VC environment by runing vcvars*.bat (choose file name

How do I use a X509 certificate with PyCrypto?

白昼怎懂夜的黑 提交于 2019-11-26 07:34:10
问题 I want to encrypt some data in python with PyCrypto. However I get an error when using key = RSA.importKey(pubkey) : RSA key format is not supported The key was generated with: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.pem The code is: def encrypt(data): pubkey = open(\'mycert.pem\').read() key = RSA.importKey(pubkey) cipher = PKCS1_OAEP.new(key) return cipher.encrypt(data) 回答1: PyCrypto does not support X.509 certificates. You must first extract the

How to decrypt OpenSSL AES-encrypted files in Python?

百般思念 提交于 2019-11-26 02:27:45
问题 OpenSSL provides a popular (but insecure – see below!) command line interface for AES encryption: openssl aes-256-cbc -salt -in filename -out filename.enc Python has support for AES in the shape of the PyCrypto package, but it only provides the tools. How to use Python/PyCrypto to decrypt files that have been encrypted using OpenSSL? Notice This question used to also concern encryption in Python using the same scheme. I have since removed that part to discourage anyone from using it. Do NOT

Encrypt & Decrypt using PyCrypto AES 256

余生长醉 提交于 2019-11-26 00:21:14
问题 I\'m trying to build two functions using PyCrypto that accept two parameters: the message and the key, and then encrypt/decrypt the message. I found several links on the web to help me out, but each one of them has flaws: This one at codekoala uses os.urandom, which is discouraged by PyCrypto. Moreover, the key I give to the function is not guaranteed to have the exact length expected. What can I do to make that happen ? Also, there are several modes, which one is recommended? I don\'t know