New version of Crypt_RSA package is available
| From: | Alexander Valyalkin | Date: | Tue, 19 Apr 2005 14:25:26 +0000 |
| Subject: | New version of Crypt_RSA package is available | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-37284@lists.php.net to get a copy of this message | ||
It is available at
http://chat.finalcombat.com/valyala/big_int/Crypt_RSA-1.0.0RC5.tgz
This package implements so much requested factory() methods for Crypt_RSA,
Crypt_RSA_Key and Crypt_RSA_KeyPair classes.
Now it is possible to use two techniques during creating objects:
// standard PEAR technique, using factory() method:
$obj = &Crypt_RSA::factory();
if (PEAR::isError($obj)) {
echo "error: ", $obj->getMessage(), "\n";
} else {
// work with correct Crypt_RSA object
}
// using constructor
$obj = &new Crypt_RSA;
if ($obj->isError()) {
$error = $obj->getLastError();
echo "error: ", $error->getMessage(), "\n";
} else {
// work with correct Crypt_RSA object
}
Each of Crypt_RSA, Crypt_RSA_Key and Crypt_RSA_KeyPair classes provides
setErrorHandler() function, which is useful for error handling.
For instance, if we have a Crypt_RSA object $rsa_obj, then we can assign our
error handler, which will be called every time during error envocation:
// error handler function
function our_handler(&$obj) {
// show error message and exit
$error = $obj->getLastError();
echo "error: ", $error->getMessage(), "\n";
exit;
}
$rsa_obj->setErrorHandler('our_handler');
// work with $rsa_obj and don't care about errors.
// All errors will be passed to our_handler() function.
See Crypt/RSA/ErrorHandler.php file for more info about setErrorHandler()
function.
See the bottom of docs/Crypt_RSA/examples/web_interface.php file for more
complex example of user's error handler, named check_error().