mcrypt_encrypt help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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))));
}

and then:

$myval="hello";
$mayval= encrypt($myval);


echo decrypt($myval);

returns "hello".... great.



But when my input string is more complicated I get unprintable characters out of the decyrpt side:

$myval="var1=1&var2=2&var3=3";

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.

Thanks,

--Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux