note 82657 deleted from ref.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:21:18 +0000 |
| Subject: | note 82657 deleted from ref.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174850@lists.php.net to get a copy of this message | ||
Note Submitter: matrix dot epokh at gmail dot com
----
Using the decrypt funciont of the Pear class Crypt_Blowfish, the decrypted text must be cleaned from
null characters (this happen when the text size is not a multiple of the cbc block size). So the
correct code should be like:
11 $plaintext = $bf->decrypt($encrypted);
12 if (PEAR::isError($plaintext)) {
13 echo $plaintext->getMessage();
14 exit;
15 }
16 // Encrypted text is padded prior to encryption
17 // so you may need to trim the decrypted result.
18 echo 'plain text: ' . trim($plaintext,"\0");