https://github.com/alextartan/flysystem-libsodium-adapter
Libsodium adapter for Flysytem
https://github.com/alextartan/flysystem-libsodium-adapter
flysystem flysystem-adapter libsodium-php
Last synced: 7 months ago
JSON representation
Libsodium adapter for Flysytem
- Host: GitHub
- URL: https://github.com/alextartan/flysystem-libsodium-adapter
- Owner: alextartan
- Created: 2019-07-23T00:03:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-17T03:39:49.000Z (over 3 years ago)
- Last Synced: 2025-09-06T01:54:30.726Z (9 months ago)
- Topics: flysystem, flysystem-adapter, libsodium-php
- Language: PHP
- Homepage:
- Size: 400 KB
- Stars: 3
- Watchers: 0
- Forks: 2
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Libsodium Adapter for Flysystem
Performing on-the-fly client-side encryption for safe storage of files.
On uploads, the content is encrypted using [Poly 1305](https://en.wikipedia.org/wiki/Poly1305) with a secret key and stored securely on the filesystem.
On downloads, the content is decrypted.
Current build status
===

[](https://codecov.io/gh/alextartan/flysystem-libsodium-adapter)
[](https://infection.github.io)
[](https://dependabot.com)
[](https://packagist.org/packages/alextartan/flysystem-libsodium-adapter)
## Installation
```bash
composer require alextartan/flysystem-libsodium-adapter
```
## Usage
```php
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](https://semver.org/)