Re: Encryption Question
| From: | Kim Steinhaug | Date: | Tue, 22 Jun 2004 21:50:32 +0000 |
| Subject: | Re: Encryption Question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188836@lists.php.net to get a copy of this message | ||
Do you really need to use stripslashes when retrieving the data?
Wouldnt stripslashes only affect magic quotes or already added slashes,
I mean when you addslashes to the SQL the slashes are indeed removed
when inserted in the table.
--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------
"Justin Patrin" <papercrane@reversefold.com> wrote in message
news:20040622181628.97275.qmail@pb1.pair.com...
> Jay Blanchard wrote:
>
> > Good morning gurus!
> >
> > I am encrypting some data on one server and now I am attempting to
decrypt on another server using mcrypt_encrypt and mycrypt_decrypt (using
same key and initialzation vector). It is almost working but I seem to still
have a little problem, that data is missing the last character which still
seems to be encrypted. I am putting the data in the database with
addslashes, and retrieving with stripslashes, but I get things like this;
> >
> > 45221141¤Þ,]¹9Ñ
> > 77777775ÿåZ|z
> >
> > while($arrEncInfo = mysql_fetch_array($dbGetSub)){
> > $stripDataA = stripslashes($arrEncInfo['dataA']);
> > $stripIV = stripslashes($arrEncInfo['iv']);
> > $dataA = mcrypt_decrypt($encAlg, $encKey, $stripDataA, $encMode,
$stripIV);
> > echo $dataA . "\n";
> > }
> >
> > Has anyone seen this? Could there be a difference between the PHP
installs? Both are version 4.3.7.
> >
> > Thanks!
> >
> > Jay
>
> You should probably use mysql_escape_string or mysql_real_escape_string
> instead of addslashes and stripslashes. IMHO addslashes and stripslashes
> are pretty much useless.
>
> --
> paperCrane <Justin Patrin>