PHP code example of hsunmr / aes-php

1. Go to this page and download the library: Download hsunmr/aes-php 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/ */

    

hsunmr / aes-php example snippets




sunmr\AES;

// encrypt
AES::encrypt($original_string, $cipher_algo, $key, $iv);

// decrypt
AES::encrypt($encrypted_string, $cipher_algo, $key, $iv);




sunmr\AES;

$original_string = 'test';
$cipher_algo     = 'AES-256-CBC';
$key             = '0USLKHBKDQQ2T9Z7IF1GNEYJLD6ZUWGO';
$iv              = 'KGOV99FKY9O9J15H';

// encrypt
$encrypted_string = AES::encrypt($original_string, $cipher_algo, $key, $iv);
var_dump($encrypted_string); //string(24) "uwZOvY9RAtYHNzuOAZ2LuA=="

// decrypt
$result = AES::decrypt($encrypted_string, $cipher_algo, $key, $iv);
var_dump($result); //string(4) "test"

composer