This is a Flysystem adapter to encrypt files on existing Flysystem adapters.
This package is not tested for now !
$ composer require league/flysystem-encryption
$ bin/flysystem-encryption /path/outside/webroot/encryption.key
<?php
use League\Flysystem\Encryption\EncryptionAdapter;
use League\Flysystem\Filesystem;
use ParagonIE\Halite\KeyFactory;
include __DIR__ . '/vendor/autoload.php';
$myAdapter = new FlysystemAdapter();
// Load the private key from a filepath with the previous command
$encKey = '/path/outside/webroot/encryption.key';
// or generate a new encryption key
$encKey = random_bytes(SODIUM_CRYPTO_STREAM_KEYBYTES);
// or save it in a file
$encKey = KeyFactory::generateEncryptionKey();
KeyFactory::save($encKey, '/path/outside/webroot/encryption.key');
$adapter = new EncryptionAdapter($myAdapter, $encKey);
$filesystem = new Filesystem($adapter);
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
MIT