Documentation

RSA.php

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:

getPublicKey(); $plaintext = 'terrafrost'; $ciphertext = $public->encrypt($plaintext); echo $private->decrypt($ciphertext); ?>

Here's an example of how to create signatures and verify signatures with this library:

getPublicKey(); $plaintext = 'terrafrost'; $signature = $private->sign($plaintext); echo $public->verify($plaintext, $signature) ? 'verified' : 'unverified'; ?>

One thing to consider when using this: so phpseclib uses PSS mode by default. Technically, id-RSASSA-PSS has a different key format than rsaEncryption. So should phpseclib save to the id-RSASSA-PSS format by default or the rsaEncryption format? For stand-alone keys I figure rsaEncryption is better because SSH doesn't use PSS and idk how many SSH servers would be able to decode an id-RSASSA-PSS key. For X.509 certificates the id-RSASSA-PSS format is used by default (unless you change it up to use PKCS1 instead)

Tags
category

Crypt

author

Jim Wigginton terrafrost@php.net

copyright

2009 Jim Wigginton

license

http://www.opensource.org/licenses/mit-license.html MIT License

link
http://phpseclib.sourceforge.net

Table of Contents

Classes

RSA
Pure-PHP PKCS#1 compliant implementation of RSA.

        
On this page

Search results