pycrypto

PyInstaller not correctly importing pycrypto… sometimes

五迷三道 提交于 2019-12-04 17:59:31
I'm packaging a project with PyInstaller on different ubuntu machines. On some of them, when executing the generated project, it throws this error: File "~/PyInstaller-2.1/proj/build/proj/out00-PYZ.pyz/Crypto.Random", line 28, in ImportError: cannot import name OSRNG However the import works perfectly ok in python console and I can execute the project without packaging it. I've tried uninstalling and reinstalling pycrypto without success, I've also tried adding a specific from Crypto.Random import OSRNG to the main file just so PyInstaller would pick it up. I was able to solve the problem with

AES 256 Encryption with PyCrypto using CBC mode - any weaknesses?

只谈情不闲聊 提交于 2019-12-04 14:08:10
I have the following python script to encrypt/decrypt data using AES 256, could you please tell me if there's anything in the code that may make the encryption weak or if there's anything that I've not taken account of for AES 256 encryption using CBC mode? I've tested the script and it works fine, it is encrypting and decrypting data but just wanted a second opinion. Thanks. from Crypto.Cipher import AES from Crypto import Random BLOCK_SIZE = 32 INTERRUPT = u'\u0001' PAD = u'\u0000' def AddPadding(data, interrupt, pad, block_size): new_data = ''.join([data, interrupt]) new_data_len = len(new

PyCrypto: Generate RSA key protected with DES3 password

半城伤御伤魂 提交于 2019-12-04 12:29:56
问题 I have been able to create a RSA key protected by password with DES3 (well... I think because I'm very new to this encryption world) by using the command: openssl genrsa -out "/tmp/myKey.pem" -passout pass:"f00bar" -des3 2048 Now, I would like to do that inside a Python script, using PyCrypto, if possible. I have seen this message, which seems to discourage the use of PyCrypto to do that. Is it still like that? Of course I can always call os.execute , and execute the above command, but I'd

PyCrypto installation error (vc\\cl.exe fails no matter what)

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:50:44
I am trying to install pyCrypto (by pip3 install pycrypto) , and I keep getting this error : Failed building wheel for pycrypto Running setup.py clean for pycrypto Failed to build pycrypto Installing collected packages: pycrypto Running setup.py install for pycrypto ... error Complete output from command c:\users\1007238\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\1007238\\AppData\\Local\\Temp\\pip-build-pm8w3iz2\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec

Decrypt using an RSA public key with PyCrypto

。_饼干妹妹 提交于 2019-12-04 06:00:05
As far as I understand, I should be able to use RSA to ensure authenticity or privacy, as I wish. In my case, I want to ensure authenticity so I encrypt the data with the private key and allow anyone to decrypt it with the public key. The data is not really secret but I need to guarantee that it was created by the owner of the public (and private) key. When I try to decrypt using PyCrypto I get No private key error from PyCrypto. The code is this: def _decrypt_rsa(decrypt_key_file, cipher_text): from Crypto.PublicKey import RSA from base64 import b64decode key = open(decrypt_key_file, "r")

How come I can't decrypted my AES encrypted message on someone elses AES decryptor?

筅森魡賤 提交于 2019-12-04 05:40:32
问题 from Crypto.Cipher import AES import os key = 'mysecretpassword' iv = os.urandom(16) plaintext1 = 'Secret Message A' encobj = AES.new(key, AES.MODE_CBC, iv) ciphertext1 = encobj.encrypt(plaintext1) encryptedText = ciphertext1.encode('base64') print encryptedText decobj = AES.new(key, AES.MODE_CBC, iv) print decobj.decrypt(ciphertext1) I copied the printed value of encryptedText and the key from my code and pasted to the websites below. http://www.everpassword.com/aes-encryptor http://www

How to generate the PEM serialization for the public RSA/DSA key

你离开我真会死。 提交于 2019-12-04 05:32:58
Using PyCrypto I was able to generate the public and private PEM serialization for a RSA key, but in PyCrypto the DSA class has no exportKey() method. Trying PyOpenSSL I was able to generate the private PEM serialization for RSA and DSA keys, bu there is no crypto.dump_publickey method in PyOpenSSL. I am looking for suggestion of how to generate the PEM serialization for RSA and DSA keys. Many thanks! PS: meanwhile I have changed the PyOpenSSL code to also export an dump_privatekey method for crypto API. PyOpenSSL bug and patch can be found at: https://bugs.launchpad.net/pyopenssl/+bug/780089

Need advice about AES CTR cipher python vs. Java

左心房为你撑大大i 提交于 2019-12-03 21:44:48
I'm working on project when some arbitrary data are encrypted using Python simple-crypt (source here ) and same encrypted data are then used in java application. I would like to understand conceptual difference between JSSE and Pycrypto. This is python part doing encryption ( source ): counter = Counter.new(HALF_BLOCK, prefix=salt[:HALF_BLOCK//8]) cipher = AES.new(cipher_key, AES.MODE_CTR, counter=counter) This is my attempt for java re-implementation of same operation: SecretKeySpec key = new SecretKeySpec(cipher_key, "AES"); IvParameterSpec ivSpec = new IvParameterSpec(salt, 0, HALF_BLOCK /

Is Python 2.7 “wide-build” usc4 not compatible with certain libraries?

…衆ロ難τιáo~ 提交于 2019-12-03 16:30:19
I required the ability to work with some unicode characters with high values, so I re-installed Python 2.7.10 with option --enable-unicode=ucs4 --prefix ("wide-build"). I then started getting the following error: ... from Crypto.Cipher import _ARC4 ImportError: /home/fast/usr/local/lib/python2.7/site-packages/Crypto/Cipher/_ARC4.so: undefined symbol: PyUnicodeUCS2_FromString I realized that undefined symbol: PyUnicodeUCS2_FromString must be because of the new build, so I then tried reinstalling everything fresh (new Python and new pip and newly installed libraries). I still had the same errors

PyCrypto in Google App Engine development server “ImportError: cannot import name blockalgo”

这一生的挚爱 提交于 2019-12-03 16:10:01
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: