Encrypt file using M2Crypto
- by Bear
It is known that I can read the whole file content in memory and encrypt it using the following code.
contents = fin.read()
cipher = M2Crypto.EVP.Cipher(alg="aes_128_cbc", key = aes_key, iv = aes_iv, op = 1)
encryptedContents = cipher.update(contents)
encryptedContents += cipher.final()
But what if the file size is large, is there a way for me to pass the input stream to M2Crypto instead of reading the whole file first?