PHP code example of pdaleramirez / asymmetric-encryption

1. Go to this page and download the library: Download pdaleramirez/asymmetric-encryption 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/ */

    

pdaleramirez / asymmetric-encryption example snippets


'providers' => [
    pdaleramirez\asymmetric\encryption\AsymmetricEncryptionProvider::class
];

'aliases' => [
    'AsymmetricEncryption' => pdaleramirez\asymmetric\encryption\AsymmetricEncryptionFacade::class
];

$textToEncrypt = 'text to encrypt';
$privateKey = file_get_contents('keys/private.key');
$publicKey = file_get_contents('keys/public.pem');

$encryptedData = \AsymmetricEncryption::encrypt($textToEncrypt, $publicKey);

$decryptedData = \AsymmetricEncryption::>decrypt($encryptedData, $privateKey);