pycrypto

Is AES-CTR in CryptoJS compatible with PyCrypto?

一曲冷凌霜 提交于 2019-12-24 05:49:59
问题 I'm trying to decrypt some AES-CTR-256 data using the PyCrypto library. The ciphertext was produced by the Cryptocat multiparty chat Javascript code, which relies on the CryptoJS library. The IV scheme is as described in the Cryptocat Multiparty Protocol Specification: The Initialization Vector (IV) is composed of 16 bytes: 12 bytes that are randomly generated and 4 bytes acting as the counter, incremented once per block. (The 12 random bytes come before the 4 counter bytes.) Here's my Python

Error importing _counter form pycrypto library

半世苍凉 提交于 2019-12-24 03:50:13
问题 This line in Crypto/Util/Counter.py from the pycrypto lib: from Crypto.Util import _counter Causes this error: ImportError: cannot import name _counter But I have the file _counter.so under Crypto/Util in the pycrypto library of Python's site-packages. I am using Python 2.7.5, 32-bit for Windows. 回答1: File _counter.so belongs to Linux/MacOS package, Windows should have _counter.pyd instead. Prebuilt Windows PyCrypto packages can be downloaded from here: http://www.voidspace.org.uk/python

Decrypt MCRYPT_RIJNDAEL_256 with 32-byte initialization vectors with PyCrypto

て烟熏妆下的殇ゞ 提交于 2019-12-23 20:58:46
问题 I have data that was encrypted in PHP as follows: mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SECRET, $data, MCRYPT_MODE_CBC, $iv) I need to decrypt this data in a Python 3 application. I am trying to use PyCrypto but I am open to other libraries. I expect the following to work: decryptor = AES.new(key, mode, IV=IV) plain = decryptor.decrypt(ciphertext) My initialization vector is 32 bytes, and the following exception is thrown: ValueError: IV must be 16 bytes long How can I set PyCrypto to use a 32

No handlers could be found for logger “paramiko.transport”

淺唱寂寞╮ 提交于 2019-12-23 06:13:08
问题 I am running some fabric tasks inside of flask. Flask is running inside of wsgi in apache. Once in a while I get this error in the apache logs: No handlers could be found for logger "paramiko.transport" I then have to restart apache for the fabric tasks that are called via flask to work again. Any ideas here... I'm running Ubuntu 12.04 Fabric==1.5.3 paramiko==1.9.0 pycrypto==2.6 Flask==0.9 回答1: Seems like the answer was to add disconnect_all() to all of my fabric functions. Now the problem

Decrypting data in Python that was encrypted in 3DES by Java

ⅰ亾dé卋堺 提交于 2019-12-22 00:57:24
问题 I'm trying to decrypt data using PyCrypto. The data was encoded in Java with the javax.crypto package. The encryption is Triple DES (referred to as "DESede" in Java). As far as I can tell, default settings are used for everything. However, when I go to decrypt the data in Python there is always a problem with the data. Here's the Java code that does encrypting/decrypting: import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; import javax.crypto.Cipher; import javax.crypto.SecretKey;

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

谁都会走 提交于 2019-12-21 20:43:46
问题 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

Include nonce and block count in PyCrypto AES MODE_CTR

爷,独闯天下 提交于 2019-12-21 15:24:51
问题 Some background information, you can skip this part for the actual question this is my third question about this topic here at stackoverflow. To be complete, these are the other questions AES with crypt-js and PyCrypto and Match AES de/encryption in python and javascript. Unfortunately my last attempt got two downvots for the original question. The problem was, even I did not know what my real question was . I just dug around to find the real question I was looking for. With the feedback in

AES decryption padding with PKCS5 Python

≡放荡痞女 提交于 2019-12-20 08:30:57
问题 I have been trying to implement AES CBC decryption in Python. Since the ciphered text is not a multiple of 16bytes, padding was necessary. Without padding, this error surfaced "TypeError: Odd-length string" But I could not find a proper reference for implementing PKCS5 in PyCrypto Python. Are there any commands to implement this? Thanks After looking into Marcus's suggestion I did this. My goal actually is to decrypt a hex message(128bytes) using this code. However, the output is " ?:" which

Encrypt in python - decrypt in Javascript

心不动则不痛 提交于 2019-12-19 09:26:17
问题 I have need to simply encrypt some text in python and being able to decrypt in JavaScrypt. So far I have in python: from Crypto import Random from Crypto.Cipher import AES import base64 BLOCK_SIZE = 16 key = "1234567890123456" # want to be 16 chars textToEncrypt = "This is text to encrypt" def encrypt(message, passphrase): # passphrase MUST be 16, 24 or 32 bytes long, how can I do that ? IV = Random.new().read(BLOCK_SIZE) aes = AES.new(passphrase, AES.MODE_CFB, IV) return base64.b64encode(aes

How AES in CTR works for Python with PyCrypto?

橙三吉。 提交于 2019-12-18 13:41:21
问题 I am using python 2.7.1 I want to encrypt sth using AES in CTR mode. I installed PyCrypto library for python. I wrote the following code: secret = os.urandom(16) crypto = AES.new(os.urandom(32), AES.MODE_CTR, counter=lambda: secret) encrypted = crypto.encrypt("asdk") print crypto.decrypt(encrypted) i have to run crypto.decrypt as many times as the byte size of my plaintext in order to get correctly the decrypted data. I.e: encrypted = crypto.encrypt("test") print crypto.decrypt(encrypted)