1. Go to this page and download the library: Download tiknil/file-vault library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/*
* The default key used for all file encryption / decryption
* This package will look for a FILE_VAULT_KEY in your env file
* If no FILE_VAULT_KEY is found, then it will use your Laravel APP_KEY
*/
'key' => env('FILE_VAULT_KEY', env('APP_KEY')),
/*
* The cipher used for encryption.
* Supported options are AES-128-CBC and AES-256-CBC
*/
'cipher' => 'AES-256-CBC',
/*
* The Storage disk used by default to locate your files.
*/
'disk' => 'local',
];
public function encrypt(string $sourceFile, string $destFile = null, $deleteSource = true)
public function encryptCopy(string $sourceFile, string $destFile = null)
FileVault::encrypt('file.txt');
FileVault::disk('s3')->encrypt('file.txt');
FileVault::encrypt('file.txt', 'encrypted.txt');
// save the encrypted copy to file.txt.enc
FileVault::encryptCopy('file.txt');
// or save the encrypted copy with a different name
FileVault::encryptCopy('file.txt', 'encrypted.txt');
public function decrypt(string $sourceFile, string $destFile = null, $deleteSource = true)
public function decryptCopy(string $sourceFile, string $destFile = null)
// save the decrypted copy to file.txt while preserving file.txt.enc
FileVault::decryptCopy('file.txt.enc');
// or save the decrypted copy with a different name, while preserving the file.txt.enc
FileVault::decryptCopy('file.txt.enc', 'decrypted.txt');