Re: mcrypt_encrypt help needed
| From: | Matijn Woudt | Date: | Wed, 30 Nov 2011 21:14:31 +0000 |
| Subject: | Re: mcrypt_encrypt help needed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-315899@lists.php.net to get a copy of this message | ||
On Wed, Nov 30, 2011 at 9:57 PM, Rick Dwyer <rpdwyer@earthlink.net> wrote:
> Hello all.
>
> I am using the following function to encrypt a string:
>
> define('SALT', 'myvalueforsalthere');
>
> function encrypt($text)
> {
> return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, SALT,
> $text, MCRYPT_MODE_ECB,
> mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
> MCRYPT_RAND))));
> }
>
Can you post your decrypt function too?
You create a random IV here, don't you need that IV to decrypt too?
> The above when decrypted will spit out a string of unprintable characters..
> Is encrypt/decrypt choking on the "=" sign? I tried:
>
> $myval=htmlentities($myval);
>
> But it did not work. Any help is appreciated.
I doubt it's choking on anything. htmlentities is only for safe output
to browser, you can always check the 'real' value by looking at the
page source in your browser.
Matijn