{"id":20504457,"url":"https://github.com/tiknil/file-vault","last_synced_at":"2026-02-14T16:05:55.688Z","repository":{"id":80089877,"uuid":"423857890","full_name":"tiknil/file-vault","owner":"tiknil","description":"A Laravel package for encrypting and decrypting files of any size","archived":false,"fork":false,"pushed_at":"2025-03-14T09:38:20.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T16:40:30.528Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"soarecostin/file-vault","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiknil.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-02T13:37:24.000Z","updated_at":"2025-09-13T10:40:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c1b1c39-d993-4f21-9d6b-3bf68630af22","html_url":"https://github.com/tiknil/file-vault","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/tiknil/file-vault","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiknil%2Ffile-vault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiknil%2Ffile-vault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiknil%2Ffile-vault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiknil%2Ffile-vault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiknil","download_url":"https://codeload.github.com/tiknil/file-vault/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiknil%2Ffile-vault/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29449053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T19:38:07.632Z","updated_at":"2026-02-14T16:05:55.670Z","avatar_url":"https://github.com/tiknil.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File encryption / decryption in Laravel\n\n## ⚠️ This is a fork of [soarecostin/file-vault](https://github.com/soarecostin/file-vault) ⚠️\n\nWe forked the repository due to abandoned state of the project in order to fix some issues we were having:\n\n-   [Fix a S3 bug returning chunk with a different than expected chunk size](https://github.com/soarecostin/file-vault/pull/20)\n-   Add Laravel 9+, PHP 8 and Flysystem v23 support\n\nRefer to the original repo for the history of opened and closed issues\n\nThe namespace has been changed from `Soarecostin/FileVault` to `Tiknil/FileVault` to allow parallel usage of both versions\n\n---\n\nWith this package, you can encrypt and decrypt files of any size in your Laravel project. This package uses streams and [CBC encryption](\u003chttps://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_Block_Chaining_(CBC)\u003e), encrypting / decrypting a segment of data at a time.\n\n## Installation and usage\n\nThis package requires PHP 8.0 and Laravel 10 or higher (use a version \u003c= 1.4 for older support)\n\nYou can install the original package via composer:\n\n```bash\ncomposer require soarecostin/file-vault\n```\n\nor this fork:\n\n```bash\ncomposer require tiknil/file-vault\n```\n\n## Usage\n\n### Tutorials\n\nFor a detailed description of how to encrypt files in Laravel using this package, please see the following articles:\n\n-   [Part 1: How to encrypt large files in Laravel](https://medium.com/swlh/how-to-encrypt-large-files-in-laravel-293460836ded?source=friends_link\u0026sk=976ab6e5d1cfb52e10c801fe0cb04fca)\n-   [Part 2: How to encrypt \u0026 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)\n\n### Description\n\nThis 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.\n\nIf you want to change the default `disk` or change the `key`/`cipher` used for encryption, you can publish the config file:\n\n```\nphp artisan vendor:publish --provider=\"SoareCostin\\FileVault\\FileVaultServiceProvider\"\n```\n\nThis is the contents of the published file:\n\n```php\nreturn [\n    /*\n     * The default key used for all file encryption / decryption\n     * This package will look for a FILE_VAULT_KEY in your env file\n     * If no FILE_VAULT_KEY is found, then it will use your Laravel APP_KEY\n     */\n    'key' =\u003e env('FILE_VAULT_KEY', env('APP_KEY')),\n\n    /*\n     * The cipher used for encryption.\n     * Supported options are AES-128-CBC and AES-256-CBC\n     */\n    'cipher' =\u003e 'AES-256-CBC',\n\n    /*\n     * The Storage disk used by default to locate your files.\n     */\n    'disk' =\u003e 'local',\n];\n```\n\n### Encrypting a file\n\nThe `encrypt` method will search for a file, encrypt it and save it in the same directory, while deleting the original file.\n\n```php\npublic function encrypt(string $sourceFile, string $destFile = null, $deleteSource = true)\n```\n\nThe `encryptCopy` method will search for a file, encrypt it and save it in the same directory, while preserving the original file.\n\n```php\npublic function encryptCopy(string $sourceFile, string $destFile = null)\n```\n\n#### Examples:\n\nThe 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`:\n\n```php\nFileVault::encrypt('file.txt');\n```\n\nYou can also specify a different `disk`, just as you would normally with the Laravel `Storage` facade:\n\n```php\nFileVault::disk('s3')-\u003eencrypt('file.txt');\n```\n\nYou 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`:\n\n```php\nFileVault::encrypt('file.txt', 'encrypted.txt');\n```\n\nThe following examples both achive the same results as above, with the only difference that the original file is not deleted:\n\n```php\n// save the encrypted copy to file.txt.enc\nFileVault::encryptCopy('file.txt');\n\n// or save the encrypted copy with a different name\nFileVault::encryptCopy('file.txt', 'encrypted.txt');\n```\n\n### Decrypting a file\n\nThe `decrypt` method will search for a file, decrypt it and save it in the same directory, while deleting the encrypted file.\n\n```php\npublic function decrypt(string $sourceFile, string $destFile = null, $deleteSource = true)\n```\n\nThe `decryptCopy` method will search for a file, decrypt it and save it in the same directory, while preserving the encrypted file.\n\n```php\npublic function decryptCopy(string $sourceFile, string $destFile = null)\n```\n\n#### Examples:\n\nThe 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`:\n\n```php\nFileVault::decrypt('file.txt.enc');\n```\n\nIf 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`:\n\n```php\nFileVault::decrypt('encrypted.txt');\n```\n\nAs with the encryption, you can also specify a different `disk`, just as you would normally with the Laravel `Storage` facade:\n\n```php\nFileVault::disk('s3')-\u003edecrypt('file.txt.enc');\n```\n\nYou 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`:\n\n```php\nFileVault::decrypt('encrypted.txt', 'decrypted.txt');\n```\n\nThe following examples both achive the same results as above, with the only difference that the original (encrypted) file is not deleted:\n\n```php\n// save the decrypted copy to file.txt while preserving file.txt.enc\nFileVault::decryptCopy('file.txt.enc');\n\n// or save the decrypted copy with a different name, while preserving the file.txt.enc\nFileVault::decryptCopy('file.txt.enc', 'decrypted.txt');\n```\n\n### Streaming a decrypted file\n\nSometimes 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:\n\n```php\nreturn response()-\u003estreamDownload(function () {\n    FileVault::streamDecrypt('file.txt')\n}, 'laravel-readme.md');\n```\n\n### Using a different key for each file\n\nYou may need to use different keys to encrypt your files. You can explicitly specify the key used for encryption using the `key` method.\n\n```php\nFileVault::key($encryptionKey)-\u003eencrypt('file.txt');\n```\n\nPlease 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.\n\nYou can generate a key with the correct length (based on the cipher specified in the config file) by using the `generateKey` method:\n\n```php\n$encryptionKey = FileVault::generateKey();\n```\n\n## Testing\n\nRun the tests with:\n\n```bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email soarecostin@gmail.com instead of using the issue tracker.\n\n## Credits\n\n-   [Costin Soare](https://github.com/soarecostin)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Laravel Package Boilerplate\n\nThis package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiknil%2Ffile-vault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiknil%2Ffile-vault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiknil%2Ffile-vault/lists"}