quickly encrypt/decrypt a file

Posted by & filed under Uncategorized.

Save this as encrypt.py and run it. You may need to “pip install pycrypto”   import os from Crypto.Cipher import AES from Crypto.Hash import SHA256 from Crypto import Random def encrypt(key, filename): chunksize = 64*1024 outputFile = ‘encrypted_’+filename filesize = str(os.path.getsize(filename)).zfill(16) IV = Random.new().read(16) encryptor = AES.new(key,AES.MODE_CBC, IV) with open(filename, ‘rb’) as infile: with open(outputFile,… Read more »