PHP code example of larryphp / encryption

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

    

larryphp / encryption example snippets



//------------------------------------------------------------------------------
      = '0000....11112222'; // the key length is 16
$encrypted = Crypt::encrypt('foo', $key); // use AES-128-CBC default
echo Crypt::decrypt($encrypted, $key); // foo
//------------------------------------------------------------------------------
// use the helper function
echo larryphp_decrypt(
    larryphp_encrypt('foo', $key), $key
); // foo
//------------------------------------------------------------------------------
// for URL application or Filenames
echo larryphp_decrypt_url(
    larryphp_encrypt_url('foo', $key), $key
); // foo
//------------------------------------------------------------------------------
$key       = '0000....111122220000....11112222'; // the key length is 32
$cipher    = 'AES-256-CBC';
$encrypted = Crypt::encrypt('foo', $key, $cipher); // must use AES-256-CBC
echo Crypt::decrypt($encrypted, $key, $cipher); // foo
//------------------------------------------------------------------------------
// use the helper function
echo larryphp_decrypt(
    larryphp_encrypt('foo', $key, $cipher), $key, $cipher
); // foo
//------------------------------------------------------------------------------
// for URL application or Filenames
echo larryphp_decrypt_url(
    larryphp_encrypt_url('foo', $key, $cipher), $key, $cipher
); // foo
//------------------------------------------------------------------------------
// Enjoy it:)
//------------------------------------------------------------------------------