Encrypt file using M2Crypto
Posted
by
Bear
on Stack Overflow
See other posts from Stack Overflow
or by Bear
Published on 2012-10-03T15:36:09Z
Indexed on
2012/10/03
15:37 UTC
Read the original article
Hit count: 213
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?
© Stack Overflow or respective owner