CRYPT_RSA_MODE
CRYPT_RSA_MODE
Pure-PHP PKCS#1 (v2.1) compliant implementation of RSA.
PHP version 5
Here's an example of how to encrypt and decrypt text with this library:
<?php
include 'vendor/autoload.php';
$rsa = new \phpseclib\Crypt\RSA(); extract($rsa->createKey());
$plaintext = 'terrafrost';
$rsa->loadKey($privatekey); $ciphertext = $rsa->encrypt($plaintext);
$rsa->loadKey($publickey); echo $rsa->decrypt($ciphertext); ?>
Here's an example of how to create signatures and verify signatures with this library:
<?php
include 'vendor/autoload.php';
$rsa = new \phpseclib\Crypt\RSA(); extract($rsa->createKey());
$plaintext = 'terrafrost';
$rsa->loadKey($privatekey); $signature = $rsa->sign($plaintext);
$rsa->loadKey($publickey); echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified'; ?>
RSA | Pure-PHP PKCS#1 compliant implementation of RSA. |