PHP code example of minvws / laravel-crypto

1. Go to this page and download the library: Download minvws/laravel-crypto 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/ */

    

minvws / laravel-crypto example snippets


  'providers' => [
      ...
      MinVWS\Laravel\Providers\CryptoServiceProvider::class,
  ];
  

class UserController {
    
    protected CmsCryptoInterface $service;
    
    function index()
    {
        $cipherText = $this->service->encrypt('plaintext');
        return new JsonResponse(['data' => $cipherText]);        
    }
}

class UserController {
    
    protected SealboxCryptoInterface $service;
    
    function index()
    {
        $cipherText = $this->service->encrypt('plaintext');
        return new JsonResponse(['data' => $cipherText]);        
    }
}

class UserController {
    
    protected SignatureCryptoInterface $service;
    
    function index()
    {
        $sig = $this->service->sign('foobar', false);
        return new JsonResponse(['signature' => $sig]);        
    }
}
 
/*/ Package Middleware /*/
    ...
    'cms_sign' => \MinVWS\Crypto\Laravel\Http\Middleware\CmsSignature::class,
 
Route::middleware('cms_sign')->post(
    '/my/route',
    [RouteController::class, 'index']
);