https://github.com/tzsk/crypton
Laravel Request & Response Encryption
https://github.com/tzsk/crypton
crypton laravel-package request-encryption response-encryption secure-api
Last synced: 10 months ago
JSON representation
Laravel Request & Response Encryption
- Host: GitHub
- URL: https://github.com/tzsk/crypton
- Owner: tzsk
- License: mit
- Created: 2019-01-22T13:58:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T20:46:00.000Z (almost 3 years ago)
- Last Synced: 2025-04-23T03:42:35.544Z (10 months ago)
- Topics: crypton, laravel-package, request-encryption, response-encryption, secure-api
- Language: PHP
- Size: 398 KB
- Stars: 41
- Watchers: 3
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# :gift: Laravel Crypton


[](https://packagist.org/packages/tzsk/crypton)
[](https://github.com/tzsk/crypton/actions?query=workflow%3ATests+branch%3Amaster)
[](https://packagist.org/packages/tzsk/crypton)
TThis is a simple package for laravel to encrypt decrypt api request & response in both ends, Backend & Javascript.
## :package: Installation
Via Composer
``` bash
$ composer require tzsk/crypton
```
Publish config file
```bash
$ php artisan crypton:publish
```
Add an environment variable in the `.env` file
```env
CRYPTON_KEY=your-encryption-key
```
## :eyes: Keep in Mind
> **TIP:** You can easily generate an encryption key by running `php artisan key:generate` then copy the generated key. Then again run: `php artisan key:generate` to make the key used by crypton and the default application key different.
**WARNING: DO NOT USE THE SAME `APP_KEY` AND `CRYPTON_KEY`**
## :fire: Usage
Start off by adding a Middleware in the `app/Http/Kernel.php` file.
```php
$routeMiddleware = [
'crypton' => \Tzsk\Crypton\Middleware\EncryptRequestResponse::class,
];
```
Now, add this middleware to any api routes or groups.
Example:
```php
Route::middleware('crypton')->post('some-endpoint', function(Request $request) {
return Post::paginate($request->per_page ? : 10);
});
```
That's it.
### :heart_eyes: Javascript adapter
[See Laravel Crypton](https://github.com/tzsk/laravel-crypton)
## :microscope: Testing
``` bash
composer test
```
## :date: Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## :crown: Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## :lock: Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## :heart: Credits
- [Kazi Ahmed](https://github.com/tzsk)
- [All Contributors](../../contributors)
## :policeman: License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.