1. Go to this page and download the library: Download sy-records/php-rsa 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/ */
sy-records / php-rsa example snippets
composer
use syrecords\Rsa;
$privateKey = './key/private_key.pem'; // Private key path
$publicKey = './key/rsa_public_key.pem'; // Public key path
$rsa = new Rsa($privateKey, $publicKey);
$originData = 'https://qq52o.me';
# Encryption with a private key
echo '<hr/>';
# Encryption with a public key
use syrecords\staticRsa;
$privateKey = file_get_contents('./key/private_key.pem'); // Private key path
$publicKey = file_get_contents('./key/rsa_public_key.pem'); // Public key path
$originData = 'https://qq52o.me';
$ecryptionData = staticRsa::privEncrypt($originData,$privateKey);
$decryptionData = staticRsa::publicDecrypt($ecryptionData,$publicKey);
echo 'The data encrypted by the private key is:' . $ecryptionData.PHP_EOL;
echo 'The data after the public key is decrypted is: ' . $decryptionData;
echo '<hr/>';
$ecryptionData = staticRsa::publicEncrypt($originData,$publicKey);
$decryptionData = staticRsa::privDecrypt($ecryptionData,$privateKey);
echo 'The data after public key encryption is:' . $ecryptionData.PHP_EOL;
echo 'The data after the private key is decrypted is:' . $decryptionData;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.