Home » Encryption » Crypt_Blowfish » Bug #4555
Return PEAR_Error instead of dying
Details
| Request #4555 | Return PEAR_Error instead of dying |
|---|---|
| Submitted | 2005-06-08 16:59 UTC |
| From | joe at joestump dot net |
| Assigned | mfonda |
| Status | Closed |
| Package | Crypt_Blowfish |
| PHP Version | Irrelevant |
| OS | All |
| Roadmaps | (Not assigned) |
Comments
[2005-06-08 16:59 UTC] joe at joestump dot net
Description:
------------
In all of the major functions you use this code:
PEAR::raiseError('Plain text must be a string', 0,
PEAR_ERROR_DIE);
As a developer I would be expecting the function to either:
a.) return true or false
b.) return a PEAR_Error
Certainly not for the function to kill my whole script if my
encryption attempt failed. For instance, if I have a web
script that takes input from the user, instead of gracefully
handling this error in my own script (ie. "Your string needs
to be plain text!" at the top of my form) the low level
library will fatally kill my script.
IMO, it should simply return a PEAR_Error on failure or true
on success (or void). That way I can do this:
$result = $blowfish->encrypt($notPlainText);
if (PEAR::isError($result)) {
// Fail gracefully
}
The main reason I propose this change: What if it's not
really a fatal error if the encryption doesn't take place?
Especially with setKey() and decrypt().