Re: Re: Decryption

From: Date: Wed, 30 Nov 2005 00:19:52 +0000
Subject: Re: Re: Decryption
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-26551@lists.php.net to get a copy of this message
I think this will solve your problems, here is real working code. class ENCRYPTION { var $KEY = "NEED_A_DECENT_KEY"; //Encrypt Function function encrypt($string) {
       $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
       $passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->KEY, $string, MCRYPT_MODE_ECB, $iv);
       $encoded = base64_encode($passcrypt);
       return $encoded;
   } 
//Decrypt Function function decrypt($string) {
       $decoded = base64_decode($string);
       $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
       $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->KEY, $decoded, MCRYPT_MODE_ECB, $iv);
       return trim($decrypted);
} } DvDmanDT wrote:
.. What exactly are you trying to do? If you are trying to decrypt user input, then no, it's not going to work.. You'll have to read the input first, then pass that to mcrypt_decrypt, then write that to your outfile..


Attachment: [application/x-pkcs7-signature] S/MIME Cryptographic Signature smime.p7s
« previous php.windows (#26551) next »