Re: Padding with mcrypt_generic
| From: | Ben Sinclair | Date: | Tue, 15 Jan 2002 15:33:04 +0000 |
| Subject: | Re: Padding with mcrypt_generic | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80572@lists.php.net to get a copy of this message | ||
That would work for me, but I have to deal with many files that I have already
encrypted and no longer know the correct sizes of. My search and replace for
the padding characters doesn't work because the files sometimes contain those
padding characters.
--
Ben Sinclair
ben@yourwebwill.com
----- Original Message -----
From: "Joe Conway (wwc)" <jconway@cox.net>
To: "Ben Sinclair" <ben@yourwebwill.com>
Cc: <php-general@lists.php.net>
Sent: Monday, January 14, 2002 7:55 PM
Subject: Re: [PHP] Padding with mcrypt_generic
> I worked around this by padding the plaintext myself. Basically, add NUL
> (character 0) bytes so that your plaintext becomes an exact multiple of
> blocksize. Then change the very last byte to the number of padding bytes
> used. If the plaintext is already an exact multiple of blocksize, then
> pad with an entire block.
>
> On decryption, reverse the process, and you'll have your original string
> back exactly the way you started.