Having worked with txt files, I'm learning about binary now. My code below works for a while then bombs out, can you point me towards a method or module to read binary data line by line? The crypto module requires a buffer (don't know how to create one of those) or a string.
from Crypto.Cipher import AES USEFILE = 'picture.bmp' class encryptData(): def __init__(self, file): blockSize = 32 self.file = file secretKey = os.urandom(blockSize) self.dataFile = open(file, "rb") cipher = AES.new(secretKey, AES.MODE_CFB) if self.dataFile: newFile = self.dataFile.readlines() for lines in newFile: print cipher.encrypt(lines) print secretKey run = encryptData(USEFILE)
I'm looking to read a binary file and encrypt it. Many thx.