PHP code example of ride / lib-encryption

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

    

ride / lib-encryption example snippets




use ride\library\encryption\cipher\GenericCipher;
use ride\library\encryption\exception\EncryptionException;
use ride\library\encryption\hash\GenericHash;

// cipher to encrypt and decrypt data
try {
    $cipher = new GenericCiper();
    $data = "Top secret mission";
    
    // if you don't have a secret key, you can generate one
    $key = $cipher->generateKey();
    
    $encrypted = $cipher->encrypt($data, $key);
    $decrypted = $cipher->decrypt($encrypted, $key); 
} catch (EncryptionException $exception) {
    // something's up!
}

// hash to generate a code of fixed size, good for passwords
$hash = new GenericHash();
$data = $hash->hash($data);