pycrypto

PyCrypto : AssertionError(“PID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()”)

假如想象 提交于 2019-12-03 11:31:49
I am creating various processes that do different tasks. One of them and only one of them, has a security module that creates the PyCrypto objects. So my program starts, creates the various processes, the process that handles messages uses the security module to decrypt and I get the following errors: firstSymKeybin = self.cipher.decrypt(encFirstSymKeybin, '') File "/usr/local/lib/python2.7/dist-packages/Crypto/Cipher/PKCS1_v1_5.py", line 206, in decrypt m = self._key.decrypt(ct) File "/usr/local/lib/python2.7/dist-packages/Crypto/PublicKey/RSA.py", line 174, in decrypt return pubkey.pubkey

pycrypto - Ciphertext with incorrect length

杀马特。学长 韩版系。学妹 提交于 2019-12-03 11:30:42
I've generated a public and private key with pycrypto, and I save them to a file using export key: from Crypto.PublicKey import RSA bits=2048 new_key = RSA.generate(bits, e=65537) prv = open('keymac.pem','w') prv.write(new_key.exportKey('PEM')) prv.close() pub = open('pubmac.pem', 'w') pub.write(new_key.publickey().exportKey('PEM')) pub.close() I use the public key to encrypt a file (following http://insiderattack.blogspot.com/2014/07/encrypted-file-transfer-utility-in.html#comment-form ) When I read the file to decrypt it, I get "Ciphertext with incorrect length." I added a try-except block

How to suppress a third-party warning using warnings.filterwarnings

余生颓废 提交于 2019-12-03 10:32:55
问题 I am using Paramiko in my python code (for sftp). Everything works fine except that everytime I import or call a paramiko function. This warning would show up: C:\Python26\lib\site-packages\Crypto\Util\randpool.py:40: RandomPool_Deprecation Warning: This application uses RandomPool, which is BROKEN in older releases. S ee http://www.pycrypto.org/randpool-broken RandomPool_DeprecationWarning) I know that this has to do with the fact that Paramiko is using some Deprecated functionalities of

PyCrypto: Generate RSA key protected with DES3 password

南楼画角 提交于 2019-12-03 08:13:46
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 consider that "cheating" :-) . I'm pretty much doing this to learn PyCrypto. Thank you in advance.

How do I create a user and set a password using ansible?

心不动则不痛 提交于 2019-12-03 07:50:26
问题 The documentation refers us to the github example, but this is a bit sparse and mysterious. It says this: # created with: # crypt.crypt('This is my Password', '$1$SomeSalt') password: $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI. but crypt.crypt doesn't emit what the example shows. It also uses MD5. I tried this: # python import crypt crypt.crypt('This is my Password', '$6$somereallyniceandbigrandomsalt$') >> '$69LxCegsnIwI' but the password field of user should get something like this: password: $6

Using pycrypto, how to import a RSA public key and use it to encrypt a string?

ぐ巨炮叔叔 提交于 2019-12-03 07:40:26
问题 The RSA public key: pubkey = 'MIGfMA0GCSqGSIb3DQEBA3UAA4GNADCBiQKBgQC35eMaYoJXEoJt5HxarHkzDBEMU3qIWE0HSQ77CwP/8UbX07W2XKwngUyY4k6Hl2M/n9TOZMZsiBzer/fqV+QNPN1m9M94eUm2gQgwkoRj5battRCaNJK/23GGpCsTQatJN8PZBhJBb2Vlsvw5lFrSdMT1R7vaz+2EeNR/FitFXwIDAQAB' how to import it and use it to encrypt a string? I tried the following code but RSA.construct() raises exception (TypeError: must be long, not str). from Crypto.PublicKey import RSA from Crypto.Util import asn1 from base64 import b64decode keyDER =

Pycrypto install fatal error: gmp.h file not found

偶尔善良 提交于 2019-12-03 04:57:55
问题 It seems like there are a number of people who have had a similar problem, however, after much searching I haven't been able to find a solution that works with my particular architecture. I'm trying to install Pycrypto (as a subsidiary of Fabric) to no avail. I'm running Mac 10.8.2, python 2.7.3 via Homebrew, and XCode 4.6 -- installing with pip or easy_install (I've tried both). From what I can tell, the problem could either be with respect to my version of XCode or because of my libraries.

在windows上安装paramiko模块

只谈情不闲聊 提交于 2019-12-03 04:24:33
###环境: windows10 X86_64 ###需求: Python中使用SSH需要用到OpenSSH,而OpenSSH依赖于paramiko模块,而paramiko模块又依赖于 pycrypto模块,因此要在Python中使用SSH。所以我们需要先安装pycrypto工具,然后再安装paramiko模块才能使用。 安装Parmiko首先要保证Python 已经安装完成。 PS: linux的安装相对简单,只需要下载安装就OK ###安装pycrypto模块: windows环境相对从官方网站下载源码安装编译会比较麻烦,或者会出现其他一些乱七八糟的问题,因为我们直接下载编译好的exe文件,选择相对应的版本即可, 网站如下: http://www.voidspace.org.uk/python/modules.shtml#pycrypto 安装点击下一步下一步就可以完成, 怎么检测成功? 只需要在Python中导入就即可,如果报错说明安装没有成功 Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32 Type “copyright”, “credits” or “license()” for more information. >>> import Crypto >>

PyCrypto not fully installed on Windows XP

自作多情 提交于 2019-12-03 02:20:04
问题 I ran python setup.py install in a Windows XP console, and it reported as follows: running install running build running build_py running build_ext warning: GMP library not found; Not building Crypto.PublicKey._fastmath. building 'Crypto.Random.OSRNG.winrandom' extension error: None When I try to run a script with import Crypto.Cipher.AES , it doesn't work, saying: ImportError: cannot import name AES How can I fix this? 回答1: On windows, it may just be easier installing PyCrypto via a prebuilt

How to suppress a third-party warning using warnings.filterwarnings

a 夏天 提交于 2019-12-03 01:03:52
I am using Paramiko in my python code (for sftp). Everything works fine except that everytime I import or call a paramiko function. This warning would show up: C:\Python26\lib\site-packages\Crypto\Util\randpool.py:40: RandomPool_Deprecation Warning: This application uses RandomPool, which is BROKEN in older releases. S ee http://www.pycrypto.org/randpool-broken RandomPool_DeprecationWarning) I know that this has to do with the fact that Paramiko is using some Deprecated functionalities of PyCrypto. My question is, is there a way to suppress this warning programmatically ? I have tried this: