Exemple #1
0
 * @category   Encryption
 * @package    Crypt_RSA
 * @author     Alexander Valyalkin <*****@*****.**>
 * @copyright  2005 Alexander Valyalkin
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * @version    1.0.0
 * @link       http://pear.php.net/package/Crypt_RSA
 */
/**
 * this test script checks factory() methods functionality
 * for Crypt_RSA, Crypt_RSA_Key and Crypt_RSA_KeyPair classes
 */
require_once dirname(__FILE__) . '/../RSA.php';
echo "Start of testing factory() methods...\n";
// try to create a Crypt_RSA object using factory() static call
$obj =& Crypt_RSA::factory();
if (PEAR::isError($obj)) {
    echo 'error in Crypt_RSA factory(): ', $obj->getMessage(), "\n";
}
// try to create a Crypt_RSA_KeyPair object using factory() static call
$obj =& Crypt_RSA_KeyPair::factory(128);
if (PEAR::isError($obj)) {
    echo 'error in Crypt_RSA_KeyPair factory(): ', $obj->getMessage(), "\n";
}
$key = $obj->getPrivateKey();
// try to create a Crypt_RSA_Key object using factory() static call
$obj =& Crypt_RSA_Key::factory($key->getModulus(), $key->getExponent(), $key->getKeyType());
if (PEAR::isError($obj)) {
    echo 'error in Crypt_RSA_KeyPair factory(): ', $obj->getMessage(), "\n";
}
echo "end\n";