pycrypto

Why must all inputs to AES be multiples of 16?

六眼飞鱼酱① 提交于 2019-11-30 09:18:56
问题 I'm using the PyCrypto implementation of AES and I'm trying to encrypt some text (24 bytes) using a 24 byte key. aes_ecb = AES.new('\x00'*24, AES.MODE_ECB) aes_ecb.encrypt("123456"*4) I get this surprising error ValueError: Input strings must be a multiple of 16 in length So why is it that my input must be a multiple of 16? It would make more sense to me that the input string length must be a multiple of my key size, because this would allow nice bitwise operations between the key and blocks

Encrypt in python and decrypt in Java with AES-CFB

倖福魔咒の 提交于 2019-11-30 07:36:04
I am aware of a question very similar to this ( How do I encrypt in Python and decrypt in Java? ) but I have a different problem. My problem is, I am not able to decrypt in Java correctly. Despite using the correct key and IV, I still get garbage characters after decryption. I don't have any compile/run-time errors or exceptions in Java so I believe I am using the right parameters for decryption. Python Encryption Code - from Crypto.Cipher import AES import base64 key = '0123456789012345' iv = 'RandomInitVector' raw = 'samplePlainText' cipher = AES.new(key,AES.MODE_CFB,iv) encrypted = base64

Trying to install pycrypto on Mac OSX mavericks

隐身守侯 提交于 2019-11-30 03:16:45
I am currently trying to install pycrypto and when I execute python setup.py build I receive this following error: cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.9-intel-2.7/src/_fastmath.o -lgmp -o build/lib.macosx-10.9-intel-2.7/Crypto/PublicKey/_fastmath.so ld: illegal text-relocation to '___gmp_binvert_limb_table' in /usr/local/lib/libgmp.a(mp_minv_tab.o) from '___gmpn_divexact_1' in /usr/local/lib/libgmp.a(dive_1.o) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'cc' failed

Different Results in Go and Pycrypto when using AES-CFB

老子叫甜甜 提交于 2019-11-29 18:56:00
问题 I am adding a go application to an already existing python codebase. I've been having trouble dealing with encryption between the languages. This is using go 1.2.1 and Python 2.7.x / PyCrypto 2.7a1. Here is the Python sample: import Crypto.Cipher import Crypto.Hash.HMAC import Crypto.Hash.SHA256 import Crypto.PublicKey.RSA from binascii import hexlify, unhexlify #encrypt payload = unhexlify("abababababababababababababababababababababababababababababababab") password = unhexlify(

PyCrypto install error on Windows

两盒软妹~` 提交于 2019-11-29 17:05:25
问题 I am trying to install PyCrypto 2.6 Library on my computer. But I keep getting the following error D:\Software\Python\package\pycrypto-2.6>python setup.py build running build running build_py running build_ext warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath. building 'Crypto.Random.OSRNG.winrandom' extension error: Unable to find vcvarsall.bat My System has Windows 8 Pro 64-bit, Visual Studio Enterprise 2012 and Python 3.3 To fix the error I tried to set the

Why must all inputs to AES be multiples of 16?

柔情痞子 提交于 2019-11-29 15:13:14
I'm using the PyCrypto implementation of AES and I'm trying to encrypt some text (24 bytes) using a 24 byte key. aes_ecb = AES.new('\x00'*24, AES.MODE_ECB) aes_ecb.encrypt("123456"*4) I get this surprising error ValueError: Input strings must be a multiple of 16 in length So why is it that my input must be a multiple of 16? It would make more sense to me that the input string length must be a multiple of my key size, because this would allow nice bitwise operations between the key and blocks of plaintext. AES is a block cipher . Quote from the Wikipedia page: “a block cipher is a deterministic

Encrypt in python and decrypt in Java with AES-CFB

一笑奈何 提交于 2019-11-29 10:11:27
问题 I am aware of a question very similar to this (How do I encrypt in Python and decrypt in Java?) but I have a different problem. My problem is, I am not able to decrypt in Java correctly. Despite using the correct key and IV, I still get garbage characters after decryption. I don't have any compile/run-time errors or exceptions in Java so I believe I am using the right parameters for decryption. Python Encryption Code - from Crypto.Cipher import AES import base64 key = '0123456789012345' iv =

Implement OpenSSL AES Encryption in Python

霸气de小男生 提交于 2019-11-29 02:45:06
I'm trying to implement the following in Python: openssl enc -e -aes-256-cbc -base64 -k "Secret Passphrase" -in plaintext.txt -out ciphertext.txt openssl enc -d -aes-256-cbc -base64 -k "Secret Passphrase" -in ciphertext.txt -out verification.txt I've tried several different modules, PyCrypto, M2Crypto, etc but can't seem to get the correct combination of changing the password to the right size key and encoding everything correctly. I've found https://github.com/nvie/SimpleAES but that basically runs OpenSSL on the command line, which I'd rather avoid. SquareRootOfTwentyThree Base 64 encoding

PyCrypto Errors with .p12 file from Google Developer Console

寵の児 提交于 2019-11-29 02:39:06
I am trying to implement Google Identity Toolkit (gitkitv3) in GAE Python. After a user signs in on the website, I get the following errors: 'PKCS12 format is not supported by the PyCrpto library. ' NotImplementedError: PKCS12 format is not supported by the PyCrpto library. Try converting to a "PEM" (openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > privatekey.pem) or using PyOpenSSL if native code is an option. Based on a SO reply , I ran the following commands on my x.p12 file and used the generated privatekey.pem file instead: openssl pkcs12 -passin pass:notasecret -in x.p12 -nocerts -passout

from Crypto import Random -> ImportError: cannot import name Random

被刻印的时光 ゝ 提交于 2019-11-29 01:38:43
I have installed pycrypto (version 2.3) to /usr/local/lib/python2.6/dist-packages/Crypto/ and I am able to see the Random package there. But when I try to import the Crypto.Random, it pomps me that from Crypto.Random import * ImportError: No module named Random Does anyone know why this would even happen? Thanks. import Crypto import os print(Crypto.__file__); print (dir(Crypto)); print(os.listdir(os.path.dirname(Crypto.__file__))) Results: /usr/lib/python2.6/dist-packages/Crypto/__init__.pyc ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__revision_