PHP code example of alejandro-ap00 / file-vault

1. Go to this page and download the library: Download alejandro-ap00/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/ */

    

alejandro-ap00 / file-vault example snippets


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',
];

$fileVault = new AlejandroAPorras\FileVault();
echo $fileVault->echoPhrase('Hello, AlejandroAPorras!');
bash
php artisan vendor:publish --tag="file-vault-config"

php artisan vendor:publish --provider="Brainstud\FileVault\FileVaultServiceProvider"
 php
FileVault::encrypt('file.txt');
 php
FileVault::disk('s3')->encrypt('file.txt');
 php
FileVault::encrypt('file.txt', 'encrypted.txt');
 php
FileVault::decrypt('file.txt.enc');
 php
FileVault::decrypt('encrypted.txt');
 php
FileVault::disk('s3')->decrypt('file.txt.enc');
 php
FileVault::decrypt('encrypted.txt', 'decrypted.txt');
 php
return response()->streamDownload(function () {
    FileVault::streamDecrypt('file.txt')
}, 'laravel-readme.md');
 php
FileVault::key($encryptionKey)->encrypt('file.txt');
 php
$encryptionKey = FileVault::generateKey();