Procedural File: RSA.php
Source Location: /lib/3rdParty/phpseclib/Crypt/RSA.php
Classes:
Crypt_RSA
Pure-PHP PKCS#1 compliant implementation of RSA.
Page Details:
Pure-PHP PKCS#1 (v2.1) compliant implementation of RSA.
PHP versions 4 and 5 Here's an example of how to encrypt and decrypt text with this library: <?php
include('Crypt/RSA.php');
$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('Crypt/RSA.php');
$plaintext = 'terrafrost';
$rsa->loadKey($privatekey);
$signature = $rsa->sign($plaintext);
$rsa->loadKey($publickey);
echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified';
?>
LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Tags:
Includes:
require_once('Math/BigInteger.php') [line 75]
Include Math_BigInteger
require_once('Crypt/Random.php') [line 80]
Include Crypt_Random
require_once('Crypt/Hash.php') [line 85]
Include Crypt_Hash
CRYPT_RSA_ENCRYPTION_OAEP [line 101]
CRYPT_RSA_ENCRYPTION_PKCS1 [line 108]
CRYPT_RSA_PRIVATE_FORMAT_PKCS1 [line 175]
CRYPT_RSA_PRIVATE_FORMAT_PUTTY [line 179]
CRYPT_RSA_PRIVATE_FORMAT_XML [line 183]
CRYPT_RSA_PUBLIC_FORMAT_OPENSSH [line 218]
CRYPT_RSA_PUBLIC_FORMAT_PKCS1 [line 208]
CRYPT_RSA_PUBLIC_FORMAT_RAW [line 204]
CRYPT_RSA_PUBLIC_FORMAT_XML [line 212]
CRYPT_RSA_SIGNATURE_PKCS1 [line 132]
CRYPT_RSA_SIGNATURE_PSS [line 125]
|