Skip to content

tzsk/crypton

Repository files navigation

๐ŸŽ Laravel Crypton

Crypton Cover Image

GitHub License Latest Version on Packagist GitHub Tests Action Status Total Downloads

TThis is a simple package for laravel to encrypt decrypt api request & response in both ends, Backend & Javascript.

๐Ÿ“ฆ Installation

Via Composer

$ composer require tzsk/crypton

Publish config file

$ php artisan crypton:publish

Add an environment variable in the .env file

CRYPTON_KEY=your-encryption-key

๐Ÿ‘€ 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

๐Ÿ”ฅ Usage

Start off by adding a Middleware in the app/Http/Kernel.php file.

$routeMiddleware = [
    'crypton' => \Tzsk\Crypton\Middleware\EncryptRequestResponse::class,
];

Now, add this middleware to any api routes or groups.

Example:

Route::middleware('crypton')->post('some-endpoint', function(Request $request) {
    return Post::paginate($request->per_page ? : 10);
});

That's it.

๐Ÿ˜ Javascript adapter

See Laravel Crypton

๐Ÿ”ฌ Testing

composer test

๐Ÿ“… Changelog

Please see CHANGELOG for more information on what has changed recently.

๐Ÿ‘‘ Contributing

Please see CONTRIBUTING for details.

๐Ÿ”’ Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

โค๏ธ Credits

๐Ÿ‘ฎโ€โ™‚๏ธ License

The MIT License (MIT). Please see License File for more information.