RE: [PHP] Re: Mcrypt functions

From: Date: Tue, 03 Jun 2003 20:34:57 +0000
Subject: RE: [PHP] Re: Mcrypt functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-150063@lists.php.net to get a copy of this message
Here,.. wait a minute. Let me pull my head out of my arse... ;o} Many thanks Jay... -daniel -----Original Message----- From: Jay Smith [mailto:jay@php.net] Sent: Tuesday, June 03, 2003 3:11 PM To: php-general@lists.php.net Subject: RE: [PHP] Re: Mcrypt functions You're using the same input for both encryption and decryption. Change the decryption line to $decrypted = mcrypt_ecb(MCRYPT_BLOWFISH, $key, $encrypted, MCRYPT_DECRYPT, $iv); srand() isn't doing anything here, you can get rid of it. Also, the IV does nothing here, it is ignored in ECB mode. Try using something like CBC mode. J Daniel Rychlik wrote: > I read more on vector IV and I agree with you. I've been reading this > manual on mcrypt_encrypt and _decrypt functions. I came up with this from > what I read and pretty much took the example. I have a problem with my > decrypt statement. Im passing what I believe is the correct params, but I > could be mistaken. > > Output from my function... > > ?Ü_ V¢¢''?Ê'ÅÆû´3?ån2V½kôR¤üyÐw?í? y}P×?õe ` <- Encrypted > Data... > 8?Ì«¢R¿?Þ6¡4±eÚ]xàLoìm > 2?*? > ê«ï " ? ez;Tê_=G?<- Decrypted data... > > code <snipit> > > srand(); > $key = "this is a secret key"; > $input = "Let us meet at 9 o'clock at the secret place."; > > $size = mcrypt_get_iv_size (MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); > > $iv = mcrypt_create_iv($size, MCRYPT_RAND); > > > $encrypted = mcrypt_ecb (MCRYPT_BLOWFISH, $key, $input, MCRYPT_ENCRYPT, > $iv); > > echo $encrypted," <- Encrypted Data...<br/>"; > > $decrypted = mcrypt_ecb (MCRYPT_BLOWFISH, $key, $input, MCRYPT_DECRYPT, > $iv); > > echo $decrypted, "<- Decrypted data...<br/>"; > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#150063) next »