Slam / flysystem-compress-and-encrypt-proxy
Compress and Encrypt files and streams before saving them to the final Flysystem destination.
Installation
To install with composer run the following command:
$ composer require slam/flysystem-compress-and-encrypt-proxyUsage
use SlamCompressAndEncryptProxy\CompressAndEncryptAdapter;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
// Create a strong key and save it somewhere
$key = EncryptedZipProxyAdapter::generateKey();
// Create the final FilesystemAdapter, for example Aws S3
$remoteAdapter = new AwsS3V3Adapter(/* ... */);
$adapter = new CompressAndEncryptAdapter(
$remoteAdapter,
$key
);
// The FilesystemOperator
$filesystem = new \League\Flysystem\Filesystem($adapter);
$handle = fopen('my-huge-file.txt', 'r');
$filesystem->writeStream('data.txt', $handle);
fclose($handle);Streams
Both write and read operations leverage streams to keep memory usage low.
Compression
GZip's zlib.deflate and zlib.inflate compression filters are used.
Encryption
Sodium extension provides the backend for the
encrypted stream with XChaCha20-Poly1305 algorithm.