Folks:

I have some code that encrypts data using a relatively long (164 characters)
alphanumeric key. 

The code for encrypt is:

$encrypted = mcrypt_cbc( MCRYPT_TripleDES, $secret_key, trim($data),
MCRYPT_ENCRYPT);

and the decrypt code is:

$decrypted = mcrypt_cbc( MCRYPT_TripleDES, $secret_key, $data,
MCRYPT_DECRYPT);

The encrypted valus is stored in a mysql database with 'addslashes' on store
and 'stripslashes' on retrieval.

When I decrypt the data, I'm getting extra whitespace characters at the end
of it. I don't get this when I test it stand-alone, but on my production
server it seems to be happening regularly. I've stopped it with trim(), but
is this a known weirdness ? I'm running PHP4.0.3pl1 and mcrypt 2.2.x on
FreeBSD 4.1.1.

Any thoughts appreciated as this is causing me some concern with respect to
the encryption/decryption process not being that robust.

tia

..Iain

--
Join Nortel Networks at CeBIT 2001 on Stand F13, Hall 17, March 22-28, 2001
in Hannover, Germany. And find out how Nortel Networks is building the
high-performance Internet.

Visit www.nortelnetworks.com/cebit for all the information you need.

Reply via email to