Skip to content

macellan/laravel-encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Encryption

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);
);