PHP code example of oyedele / crypto-helper

1. Go to this page and download the library: Download oyedele/crypto-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oyedele / crypto-helper example snippets


'providers' => [
    // ...
    Oyedele\CryptoHelper\CryptoHelperServiceProvider::class,
];

return [
    'cipher'  => 'AES-128-ECB',
    'options' => OPENSSL_RAW_DATA,
];

use Oyedele\CryptoHelper\CryptoHelper;

// Encrypt
$encrypted = CryptoHelper::encrypt('my-secret-data', 'my-secret-key');

// Decrypt
$decrypted = CryptoHelper::decrypt($encrypted, 'my-secret-key');

echo $decrypted; // "my-secret-data"

config(['crypto-helper.key' => 'my-default-key']);

$encrypted = CryptoHelper::encrypt('data'); // uses default key



use Oyedele\CryptoHelper\Config;
use Oyedele\CryptoHelper\CryptoHelper;

// Set encryption key globally
Config::set('key', 'my-standalone-key');

// Encrypt
$encrypted = CryptoHelper::encrypt('standalone-data');

// Decrypt
$decrypted = CryptoHelper::decrypt($encrypted);

echo $decrypted; // "standalone-data"
bash
php artisan vendor:publish --tag=config

config/crypto-helper.php

crypto-helper/
├── config/
│   └── crypto-helper.php       # Default config
├── src/
│   ├── Config.php              # Standalone config manager
│   ├── CryptoHelper.php        # Core encryption/decryption
│   └── CryptoHelperServiceProvider.php # Laravel provider
├── tests/
│   └── CryptoHelperTest.php    # PHPUnit tests
└── README.md