zendframework/zf2 — pull request #6410 by ezimuel (2014-06-24 14:19:59+00:00)
Title: Added the file encryption/decryption functions in BlockCipher

I added the following functions to `Zend\Crypt\BlockCipher`:
- `encryptFile($fileIn, $fileOut, $compress = true)`
- `decryptFile($fileIn, $fileOut, $compress = true)`

where `$fileIn` is the input file to encrypt/decrypt and `$fileOut` is the output file. You can enable or disable the compression of the file using the last optional parameter, `$compress`. The compression is managed using the `compress.zlib://` stream and it's done before the encryption, following the best practices of applied cryptography.
These functions can be used to encrypt/decrypt files of any dimension. I used a buffer memory of 1 MB to read the files, block by block.The encryption of file follows the same procedure of `encrypt()`, using **encryption-then-authenticate** approach with HMAC (SHA256 by default).