1. Go to this page and download the library: Download devuri/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/ */
devuri / encryption example snippets
use Urisoft\EncryptionKey;
// Generate a new encryption key
$key = EncryptionKey::generate_key();
// Store the generated key securely (e.g., in a secret key file) for future use.
use Urisoft\Encryption;
use Urisoft\Filesystem;
// Replace these with the appropriate values for your application
$rootDirPath = __DIR__;
$filesystem = new Filesystem(); // Optional, , $keyId);
} catch (InvalidArgumentException $e) {
// Handle exception if the secret key file is not found
}
$dataToEncrypt = 'This is sensitive data';
$encryptedData = $encryption->encrypt($dataToEncrypt);
// Optionally, encode the encrypted data in base64
$base64EncodedData = $encryption->encrypt($dataToEncrypt, true);
$encryptedData = '...'; // Replace this with the actual encrypted data
$decryptedData = $encryption->decrypt($encryptedData);
// Optionally, if the encrypted data was base64-encoded
$base64EncodedData = '...'; // Replace this with the actual base64-encoded data
$decodedDecryptedData = $encryption->decrypt($base64EncodedData, true);
if ($decryptedData === null || $decodedDecryptedData === null) {
// Decryption failed or wrong key was loaded
// Handle the error accordingly
}
use Urisoft\OpenSSLEncrypt;
$key = 'your-encryption-key'; // Replace with your secure key.
$cipher = 'AES-128-CBC'; // Optional, default is AES-128-CBC.
$encryptor = new OpenSSLEncrypt($key, $cipher);
$inputFormat = 'base64'; // Should match the format used in encryption. Default is base64.
$decryptedText = $encryptor->decrypt($encryptedText, $inputFormat);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.