alextartan / flysystem-libsodium-adapter
On-the-fly encrypt and decrypt flysystem files
Package info
github.com/alextartan/flysystem-libsodium-adapter
pkg:composer/alextartan/flysystem-libsodium-adapter
Requires
- php: >=7.4
- ext-sodium: *
- alextartan/helpers: 2.0.*
- league/flysystem: ^1.0.63
- league/flysystem-adapter-decorator: ^1.0.0
- league/flysystem-aws-s3-v3: ^1.0.23
- monolog/monolog: ^2.0.2
Requires (Dev)
- ext-openssl: *
- infection/infection: ^0.15.0
- league/flysystem-memory: ^1.0.2
- php-coveralls/php-coveralls: ^2.2.0
- phpstan/phpstan: ^0.12.5
- phpstan/phpstan-phpunit: ^0.12.6
- phpstan/phpstan-strict-rules: ^0.12.1
- phpunit/phpunit: ^8.5.2
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: 3.5.*
- symfony/var-dumper: ^5.0.2
This package is auto-updated.
Last update: 2026-05-17 11:52:55 UTC
README
Performing on-the-fly client-side encryption for safe storage of files.
On uploads, the content is encrypted using Poly 1305 with a secret key and stored securely on the filesystem.
On downloads, the content is decrypted.
Current build status
Installation
composer require alextartan/flysystem-libsodium-adapter
Usage
use AlexTartan\Flysystem\Adapter\ChunkEncryption\Libsodium;use AlexTartan\Flysystem\Adapter\EncryptionAdapterDecorator; use League\Flysystem\Filesystem; use League\Flysystem\Memory\MemoryAdapter; $adapter = new MemoryAdapter(); $encryption = Libsodium::factory($encryptionKey, 4096); $adapterDecorator = new EncryptionAdapterDecorator( $adapter, $encryption ); $filesystem = new Filesystem($adapterDecorator);
Notice;
Due to how AwsS3 (and probably other remote adapters) handle stream uploads,
I had to change the way this lib worked (versions up to v.1.0.0)
New releases employ a php://temp stream in which the encryption is done
and once that finishes, the stream is sent to writeStream/readStream
Performance wise, it handles ok from what i could see.
Versioning
This library adheres to semver