Re: mcrypt_encrypt help needed

From: Date: Wed, 30 Nov 2011 22:13:37 +0000
Subject: Re: mcrypt_encrypt help needed
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-315908@lists.php.net to get a copy of this message
On Wed, Nov 30, 2011 at 10:57 PM, Rick Dwyer <rpdwyer@earthlink.net> wrote: > My decrypt is below: > > $myval=$_GET["myval"]; > > > // let the encryption begin > > define('SALT', 'myvalueforsalthere'); > > function decrypt($text) > { >    return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, SALT, > base64_decode($text), MCRYPT_MODE_ECB, > mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), > MCRYPT_RAND))); > } > > echo decrypt($myval); > > Your decrypt function seems fine, and the encrypt/decrypt functions work fine both in the same file for me. Now you say you use $_GET["myval"], which means you get them from URL. Base64 is not URL safe, have you used urlencode()? Matijn

« previous php.general (#315908) next »