Skip to content

Commit 695a3a3

Browse files
committed
Updated repo to Tiknil namespace
1 parent 6b2cde9 commit 695a3a3

File tree

7 files changed

+86
-48
lines changed

7 files changed

+86
-48
lines changed

README.md

Lines changed: 66 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,58 @@
11
# File encryption / decryption in Laravel
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/soarecostin/file-vault.svg?style=flat-square)](https://packagist.org/packages/soarecostin/file-vault)
4-
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5-
[![Build Status](https://img.shields.io/travis/soarecostin/file-vault/master.svg?style=flat-square)](https://travis-ci.org/soarecostin/file-vault)
6-
[![Quality Score](https://img.shields.io/scrutinizer/g/soarecostin/file-vault.svg?style=flat-square)](https://scrutinizer-ci.com/g/soarecostin/file-vault)
7-
[![StyleCI](https://styleci.io/repos/221933072/shield)](https://styleci.io/repos/221933072)
8-
[![Total Downloads](https://img.shields.io/packagist/dt/soarecostin/file-vault.svg?style=flat-square)](https://packagist.org/packages/soarecostin/file-vault)
3+
## ⚠️ This is a fork of [soarecostin/file-vault](https://github.com/soarecostin/file-vault) ⚠️
94

10-
With this package, you can encrypt and decrypt files of any size in your Laravel project. This package uses streams and [CBC encryption](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_(CBC)), encrypting / decrypting a segment of data at a time.
5+
We forked the repository due to abandoned state of the project in order to fix some issues we were having:
116

7+
- [Fix a S3 bug returning chunk with a different than expected chunk size](https://github.com/soarecostin/file-vault/pull/20)
8+
- Add Laravel 9, PHP 8 and Flysystem v23 support
9+
10+
Refer to the original repo for the history of opened and closed issues
11+
12+
The namespace has been changed from `Soarecostin/FileVault` to `Tiknil/FileVault` to allow parallel usage of both versions
13+
14+
---
15+
16+
With this package, you can encrypt and decrypt files of any size in your Laravel project. This package uses streams and [CBC encryption](<https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_(CBC)>), encrypting / decrypting a segment of data at a time.
1217

1318
## Installation and usage
1419

15-
This package requires PHP 7.2 and Laravel 5.8 or higher.
20+
This package requires PHP 7.2 and Laravel 5.8 or higher.
1621

17-
You can install the package via composer:
22+
You can install the original package via composer:
1823

1924
```bash
2025
composer require soarecostin/file-vault
2126
```
2227

28+
or this fork by adding the reference to the github repo in your composer.json:
29+
30+
```php
31+
"repositories": [
32+
{
33+
"type": "vcs",
34+
"url": "https://github.com/tiknil/file-vault"
35+
}
36+
],
37+
```
38+
39+
and then
40+
41+
```bash
42+
composer require tiknil/file-vault
43+
```
44+
2345
## Usage
2446

2547
### Tutorials
48+
2649
For a detailed description of how to encrypt files in Laravel using this package, please see the following articles:
27-
- [Part 1: How to encrypt large files in Laravel](https://medium.com/swlh/how-to-encrypt-large-files-in-laravel-293460836ded?source=friends_link&sk=976ab6e5d1cfb52e10c801fe0cb04fca)
28-
- [Part 2: How to encrypt & upload large files to Amazon S3 in Laravel](https://medium.com/@soarecostin/how-to-encrypt-upload-large-files-to-amazon-s3-in-laravel-af88324a9aa?sk=a9a358a3892e898a60448d5314fb3dc0)
50+
51+
- [Part 1: How to encrypt large files in Laravel](https://medium.com/swlh/how-to-encrypt-large-files-in-laravel-293460836ded?source=friends_link&sk=976ab6e5d1cfb52e10c801fe0cb04fca)
52+
- [Part 2: How to encrypt & upload large files to Amazon S3 in Laravel](https://medium.com/@soarecostin/how-to-encrypt-upload-large-files-to-amazon-s3-in-laravel-af88324a9aa?sk=a9a358a3892e898a60448d5314fb3dc0)
2953

3054
### Description
55+
3156
This package will automatically register a facade called `FileVault`. The `FileVault` facade is using the Laravel `Storage` and will allow you to specify a `disk`, just as you would normally do when working with Laravel Storage. All file names/paths that you will have to pass into the package encrypt/decrypt functions are relative to the disk root folder. By default, the `local` disk is used, but you can either specify a different disk each time you call one of `FileVault` methods, or you can set the default disk to something else, by publishing this package's config file.
3257

3358
If you want to change the default `disk` or change the `key`/`cipher` used for encryption, you can publish the config file:
@@ -37,7 +62,8 @@ php artisan vendor:publish --provider="SoareCostin\FileVault\FileVaultServicePro
3762
```
3863

3964
This is the contents of the published file:
40-
``` php
65+
66+
```php
4167
return [
4268
/*
4369
* The default key used for all file encryption / decryption
@@ -59,41 +85,43 @@ return [
5985
];
6086
```
6187

62-
6388
### Encrypting a file
6489

6590
The `encrypt` method will search for a file, encrypt it and save it in the same directory, while deleting the original file.
6691

67-
``` php
92+
```php
6893
public function encrypt(string $sourceFile, string $destFile = null, $deleteSource = true)
6994
```
7095

7196
The `encryptCopy` method will search for a file, encrypt it and save it in the same directory, while preserving the original file.
7297

73-
``` php
98+
```php
7499
public function encryptCopy(string $sourceFile, string $destFile = null)
75100
```
76101

77-
78102
#### Examples:
79103

80104
The following example will search for `file.txt` into the `local` disk, save the encrypted file as `file.txt.enc` and delete the original `file.txt`:
81-
``` php
105+
106+
```php
82107
FileVault::encrypt('file.txt');
83108
```
84109

85110
You can also specify a different `disk`, just as you would normally with the Laravel `Storage` facade:
86-
``` php
111+
112+
```php
87113
FileVault::disk('s3')->encrypt('file.txt');
88114
```
89115

90116
You can also specify a different name for the encrypted file by passing in a second parameter. The following example will search for `file.txt` into the `local` disk, save the encrypted file as `encrypted.txt` and delete the original `file.txt`:
91-
``` php
117+
118+
```php
92119
FileVault::encrypt('file.txt', 'encrypted.txt');
93120
```
94121

95122
The following examples both achive the same results as above, with the only difference that the original file is not deleted:
96-
``` php
123+
124+
```php
97125
// save the encrypted copy to file.txt.enc
98126
FileVault::encryptCopy('file.txt');
99127

@@ -105,40 +133,45 @@ FileVault::encryptCopy('file.txt', 'encrypted.txt');
105133

106134
The `decrypt` method will search for a file, decrypt it and save it in the same directory, while deleting the encrypted file.
107135

108-
``` php
136+
```php
109137
public function decrypt(string $sourceFile, string $destFile = null, $deleteSource = true)
110138
```
111139

112140
The `decryptCopy` method will search for a file, decrypt it and save it in the same directory, while preserving the encrypted file.
113141

114-
``` php
142+
```php
115143
public function decryptCopy(string $sourceFile, string $destFile = null)
116144
```
117145

118146
#### Examples:
119147

120148
The following example will search for `file.txt.enc` into the `local` disk, save the decrypted file as `file.txt` and delete the encrypted file `file.txt.enc`:
121-
``` php
149+
150+
```php
122151
FileVault::decrypt('file.txt.enc');
123152
```
124153

125154
If the file that needs to be decrypted doesn't end with the `.enc` extension, the decrypted file will have the `.dec` extention. The following example will search for `encrypted.txt` into the `local` disk, save the decrypted file as `encrypted.txt.dec` and delete the encrypted file `encrypted.txt`:
126-
``` php
155+
156+
```php
127157
FileVault::decrypt('encrypted.txt');
128158
```
129159

130160
As with the encryption, you can also specify a different `disk`, just as you would normally with the Laravel `Storage` facade:
131-
``` php
161+
162+
```php
132163
FileVault::disk('s3')->decrypt('file.txt.enc');
133164
```
134165

135166
You can also specify a different name for the decrypted file by passing in a second parameter. The following example will search for `encrypted.txt` into the `local` disk, save the decrypted file as `decrypted.txt` and delete the original `encrypted.txt`:
136-
``` php
167+
168+
```php
137169
FileVault::decrypt('encrypted.txt', 'decrypted.txt');
138170
```
139171

140172
The following examples both achive the same results as above, with the only difference that the original (encrypted) file is not deleted:
141-
``` php
173+
174+
```php
142175
// save the decrypted copy to file.txt while preserving file.txt.enc
143176
FileVault::decryptCopy('file.txt.enc');
144177

@@ -150,7 +183,7 @@ FileVault::decryptCopy('file.txt.enc', 'decrypted.txt');
150183

151184
Sometimes you will only want to allow users to download the decrypted file, but you don't need to store the actual decrypted file. For this, you can use the `streamDecrypt` function that will decrypt the file and will write it to the `php://output` stream. You can use the Laravel [`streamDownload` method](https://laravel.com/docs/6.x/responses#file-downloads) (available since 5.6) in order to generate a downloadable response:
152185

153-
``` php
186+
```php
154187
return response()->streamDownload(function () {
155188
FileVault::streamDecrypt('file.txt')
156189
}, 'laravel-readme.md');
@@ -160,23 +193,23 @@ return response()->streamDownload(function () {
160193

161194
You may need to use different keys to encrypt your files. You can explicitly specify the key used for encryption using the `key` method.
162195

163-
``` php
196+
```php
164197
FileVault::key($encryptionKey)->encrypt('file.txt');
165198
```
166199

167200
Please note that the encryption key must be 16 bytes long for the `AES-128-CBC` cipher and 32 bytes long for the `AES-256-CBC` cipher.
168201

169202
You can generate a key with the correct length (based on the cipher specified in the config file) by using the `generateKey` method:
170203

171-
``` php
204+
```php
172205
$encryptionKey = FileVault::generateKey();
173206
```
174207

175208
## Testing
176209

177210
Run the tests with:
178211

179-
``` bash
212+
```bash
180213
composer test
181214
```
182215

@@ -194,8 +227,8 @@ If you discover any security related issues, please email soarecostin@gmail.com
194227

195228
## Credits
196229

197-
- [Costin Soare](https://github.com/soarecostin)
198-
- [All Contributors](../../contributors)
230+
- [Costin Soare](https://github.com/soarecostin)
231+
- [All Contributors](../../contributors)
199232

200233
## License
201234

composer.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "soarecostin/file-vault",
2+
"name": "tiknil/file-vault",
33
"description": "",
44
"keywords": [
55
"laravel",
@@ -12,14 +12,19 @@
1212
"file",
1313
"file-vault"
1414
],
15-
"homepage": "https://github.com/soarecostin/file-vault",
15+
"homepage": "https://github.com/tiknil/file-vault",
1616
"license": "MIT",
1717
"type": "library",
1818
"authors": [
1919
{
2020
"name": "Costin Soare",
2121
"email": "soarecostin@gmail.com",
22-
"role": "Developer"
22+
"role": "Original Developer"
23+
},
24+
{
25+
"name": "Giorgio Balduzzi",
26+
"email": "balduzzi.giorgio@tiknil.com",
27+
"role": "Fork Developer"
2328
}
2429
],
2530
"require": {
@@ -32,12 +37,12 @@
3237
},
3338
"autoload": {
3439
"psr-4": {
35-
"SoareCostin\\FileVault\\": "src"
40+
"Tiknil\\FileVault\\": "src"
3641
}
3742
},
3843
"autoload-dev": {
3944
"psr-4": {
40-
"SoareCostin\\FileVault\\Tests\\": "tests"
45+
"Tiknil\\FileVault\\Tests\\": "tests"
4146
}
4247
},
4348
"scripts": {
@@ -50,10 +55,10 @@
5055
"extra": {
5156
"laravel": {
5257
"providers": [
53-
"SoareCostin\\FileVault\\FileVaultServiceProvider"
58+
"Tiknil\\FileVault\\FileVaultServiceProvider"
5459
],
5560
"aliases": {
56-
"FileVault": "SoareCostin\\FileVault\\Facades\\FileVault"
61+
"FileVault": "Tiknil\\FileVault\\Facades\\FileVault"
5762
}
5863
}
5964
}

src/Facades/FileVault.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SoareCostin\FileVault\Facades;
3+
namespace Tiknil\FileVault\Facades;
44

55
use Illuminate\Support\Facades\Facade;
66

@@ -12,7 +12,7 @@
1212
* @method static mixed decrypt(string $sourceFile, string $destFile = null, $deleteSource = true)
1313
* @method static mixed decryptCopy(string $sourceFile, string $destFile = null)
1414
*
15-
* @see \SoareCostin\FileVault\FileVault
15+
* @see \Tiknil\FileVault\FileVault
1616
*/
1717
class FileVault extends Facade
1818
{

src/FileEncrypter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SoareCostin\FileVault;
3+
namespace Tiknil\FileVault;
44

55
use Exception;
66
use Illuminate\Support\Str;

src/FileVault.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SoareCostin\FileVault;
3+
namespace Tiknil\FileVault;
44

55
use Illuminate\Support\Facades\Storage;
66
use Illuminate\Support\Str;

src/FileVaultServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SoareCostin\FileVault;
3+
namespace Tiknil\FileVault;
44

55
use Illuminate\Support\ServiceProvider;
66

tests/FileVaultTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace SoareCostin\FileVault\Tests;
3+
namespace Tiknil\FileVault\Tests;
44

55
use Illuminate\Support\Facades\Storage;
66
use Orchestra\Testbench\TestCase;
7-
use SoareCostin\FileVault\Facades\FileVault;
8-
use SoareCostin\FileVault\FileVaultServiceProvider;
7+
use Tiknil\FileVault\Facades\FileVault;
8+
use Tiknil\FileVault\FileVaultServiceProvider;
99

1010
class FileVaultTest extends TestCase
1111
{

0 commit comments

Comments
 (0)