This bundle provide file encryption with AES-256 Cipher The amount of memory used is independant of the file you encrypt.
The original file is read by the chunk_file_size
and the encryption is done on this amount of data
A folder is created in the temp_folder
with the name of the original encrypted file
Each encrypted part are written in this folder
By passing the original file name to the decryptFile
method, the cryptoBundle use the corresponding folder with encrypted parts of the file to rebuild the original file
- Add to your composer file
{
"require": {
...
"dterranova/crypto-bundle": "dev-master"
}
...
}
-
Update your vendors
php composer.phar update
-
Add to your AppKernel
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new dterranova\Bundle\CryptoBundle\dterranovaCryptoBundle(),
// ...
);
}
- Add to your
app/config/config.yml
# app/config/config.yml
dterranova_crypto:
temp_folder: "%kernel.root_dir%/../web/YOUR_TEMP_FOLDER"
chunk_file_size: 2 # The size (in Mb) of chunked files, more it is big more it will consume memory
- Encrypt a file
$cryto = $this->get("dterranova_crypto.crypto_adapter");
$crypto->encryptFile(ABSOLUTE_FILE_PATH, KEY);
- Decrypt a file
$cryto = $this->get("dterranova_crypto.crypto_adapter");
$crypto->decryptFile(ABSOLUTE_FILE_PATH, KEY, true); // The same absolute file path