PHP code example of ferdhika31 / php-crispy

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

    

ferdhika31 / php-crispy example snippets


use Ferdhika31\PhpCrispy\Aesx;

$key = "1234567890123456"; // 16 bytes = AES-128
$encrypted = Aesx::encryptCBC($key, "My Secret Data");
$decrypted = Aesx::decryptCBC($key, $encrypted);

use Ferdhika31\PhpCrispy\Digestx;

$hex = Digestx::sha256Hex("hello", " ", "world"); 

use Ferdhika31\PhpCrispy\Hmacx;

$key = "super_secret_key_that_is_long_enough..";
$hmac = Hmacx::md5Hex($key, "My payload");

use Ferdhika31\PhpCrispy\Rsax;

// Generate pairs
$keys = Rsax::generateKeyPairs(2048);

// Sign Data
$signature = Rsax::signSha256($keys['private'], "Important Payload");

// Verify Data
$isValid = Rsax::verifySignSha256($keys['public'], "Important Payload", $signature);
bash
composer 
bash
php examples/aes_sample.php
php examples/digest_sample.php
php examples/hmac_sample.php
php examples/rsa_sample.php