macellan / laravel-encryption
Provides flexible data encryption adapter for Laravel.
Installs: 203
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.4|^8.0
README
Provides flexible data encryption adapter for Laravel. 2-step encryption is available. Adapter settings are encrypted with "encryption_key". Data is encrypted with adapters.
Requirement PHP 7.4+.
Installation
- Install Package
composer req macellan/laravel-encryption
- Preparing Database & Config File
php artisan vendor:publish --tag="encryption"
- Run Migrations
php artisan migrate
- Default Configuration: config/encryption.php
<?php return [ /* |-------------------------------------------------------------------------- | Encrypt Adapter Options |-------------------------------------------------------------------------- */ 'options_encrypt' => true, /* |-------------------------------------------------------------------------- | Options Encryption Key. |-------------------------------------------------------------------------- */ 'encryption_key' => env('ENCRYPTION_KEY'), /* |-------------------------------------------------------------------------- | Encryption Adapters |-------------------------------------------------------------------------- */ 'adapters' => [ \Macellan\LaravelEncryption\Adapters\LocalAdapter::class, ], ];
Provider Commands
- List Provider:
php artisan encryption:list
- Create Provider:
php artisan encryption:create
- Edit Provider:
php artisan encryption:edit
- List Provider:
php artisan encryption:remove
- List Provider:
php artisan encryption:key:generate
Usage
<?php $data = [1,2,3]; // Data Encrypt-Decrypt $encrypt = app('encryption')->encrypt($data); $decrypt = app('encryption')->decrypt($encrypt)->data(); // Custom Encryption Provider $decrypt = app('encryption')->decrypt( new CryptedData(EncryptionProvider $provider, $cryptedData); );