pycrypto

Python PyCrypto encrypt/decrypt text files with AES

走远了吗. 提交于 2019-12-18 10:21:37
问题 I already have a working program, but the only thing that doesn't work is the decrypt_file() function I have. I can still copy the encrypted text from the file and put it in my decrypt() function and have it work, but when I try to use my supposed-to-be handy decrypt_file() function it throws an error. Now I know 99.999% sure that my encrypt() and decrypt() functions are fine, but there is something with the bytes and strings conversion when I read and encode the text file that throws an

Implement OpenSSL AES Encryption in Python

房东的猫 提交于 2019-12-18 03:46:28
问题 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

SignedJwtAssertionCredentials on AppEngine doesn't recognize PEM key

南笙酒味 提交于 2019-12-17 17:58:08
问题 SignedJwtAssertionCredentials on appengine (with pycrypto 2.6) doesn't support the PKCS12 format, therefore I'm trying to use PEM keys instead, as suggested everywhere.. this is my code: f = file(os.path.join(os.path.dirname(__file__), KEY_FILE), "r") key = f.read() f.close() credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key, scope="https://www.googleapis.com/auth/drive" http = httplib2.Http() http = credentials.authorize(http) and the KEY_FILE is a PEM key, converted

Broken Pipe error when using pip to install pycrypto on Mac OS X

杀马特。学长 韩版系。学妹 提交于 2019-12-17 10:28:07
问题 I am attempting to install pycrypto (version 2.3) on OS X via pip. I am getting a "Broken pipe" error when the compiler attempts to compile MD2.c. I get a very similar error when using easy_install. Here is the error that I am getting: bash-3.2$ bash-3.2$ sudo pip install pycrypto Password: Downloading/unpacking pycrypto Running setup.py egg_info for package pycrypto Installing collected packages: pycrypto Running setup.py install for pycrypto warning: GMP library not found; Not building

How do I install PyCrypto on Windows?

时光总嘲笑我的痴心妄想 提交于 2019-12-17 02:19:08
问题 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

How do I install PyCrypto on Windows?

爱⌒轻易说出口 提交于 2019-12-17 02:18:30
问题 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

Python AES Decryption Routine (Code Help)

社会主义新天地 提交于 2019-12-13 19:19:23
问题 I developed a code based on information available online regarding an AES Encryption and Decryption routine. Language: Python 2.7.x Complete Code - #!/usr/bin/python import sys, os import hashlib import base64 from Crypto.Cipher import AES ## Variables in computation. IV = u'1234567890123456' BLOCK_SIZE = 32 INTERRUPT = u'\u0001' PAD = u'\u0000' SECRET = os.urandom(32) filename=sys.argv[1] def AddPadding(data, interrupt, pad, block_size): new_data = ''.join([data, interrupt]) new_data_len =

Difficult to install python ssh library on windows (ssh has been replaced with “paramiko”)

白昼怎懂夜的黑 提交于 2019-12-13 18:41:50
问题 I'm going to place both my question and answer here, since I had a very difficult time figuring it out. (Also I started out trying to install the "ssh" library, but it has been superceded by the "paramiko" library of the same function. I may have missed a replacement here, please forgive if I have.) Question: I need to install the "paramiko" library on a windows 7 system. Pip and easy_install both give errors when trying to install the "Crypto" module. I headed down a number of blind alleys

Python pyCrypto RSA encrypt method gives same results using private or public key

巧了我就是萌 提交于 2019-12-13 17:03:11
问题 I'm trying to understand the pyCrypto encrypt and decrypt methods for public and private keys, and I'm seeing something strange. Suppose I have a set of private and public keys, stored in files dummy_private.txt and dummy_public.txt. I create a private key object and public key object like this: private_key_file='dummy_private.txt' f = open(private_key_file, 'r') privateKey = RSA.importKey(f.read(),None) f.close() public_key_file='dummy_public.txt' f = open(public_key_file, 'r') publicKey =

Import CSP blob exported from .NET into python pyCrypto

末鹿安然 提交于 2019-12-13 16:45:00
问题 I have a CPS Blob exported from certificate using RSACryptoServiceProvider.ExportCspBlob in my .NET application. return Convert.ToBase64String(rsaAlg.ExportCspBlob(false /*includePrivateParameters*/)); Now, I need to import that blob in python application. I tried using pyCrypto, but with no luck. # that's the value I'm getting from .NET code above key = 'BgIAAAAkAABSU0ExAAgAAAEAAQARMnLlzOgHkmHssf6ZSFJn8TlTiOBSoRSEnkI4U0UI6n1jFY2bTWS9O5uApMNXz1vr5OyxoXsNVF2XrNM4DOC+lRn3R/H