Skip to content

swisnl/flysystem-encrypted

Repository files navigation

Flysystem Encrypted Filesystem Adapter

Latest Version on Packagist Software License Buy us a tree Build Status Coverage Status Quality Score Total Downloads Made by SWIS

This Flysystem adapter is a transparent decorator that encrypts/decrypts files using the Illuminate Encrypter.

Install

Via Composer

$ composer require swisnl/flysystem-encrypted

N.B. Using Flysystem 1? Please use version 1.x of this adapter.

Usage

use Illuminate\Encryption\Encrypter;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use Swis\Flysystem\Encrypted\EncryptedFilesystemAdapter;

// Create the adapter
$localAdapter = new Local('/path/to/root');

// Create the encrypter
$encrypter = new Encrypter('key', 'cipher');

// Decorate the adapter
$adapter = new EncryptedFilesystemAdapter($localAdapter, $encrypter);

// And use that to create the file system
$filesystem = new Filesystem($adapter);

Known limitations

  1. Encrypted data is — depending on what you encrypt — roughly 30-40% bigger.
  2. You can use streams with this adapter, but internally they will always be converted to a string because the entire file contents need to be encrypted/decrypted at once. This requires quite some memory, so this adapter is not recommended for large files.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email security@swis.nl instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

SWIS ❤️ Open Source

SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.