note 30516 deleted from ref.mcrypt by derick

From: Date: Fri, 25 Apr 2003 19:13:18 +0000
Subject: note 30516 deleted from ref.mcrypt by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47113@lists.php.net to get a copy of this message
I had some problems using the examples on mcrypt, so I wrote this class which is derivative of (paul at xmill dot com)'s example: *note that this example uses PHP 4.1.2 with lib mcrypt 2.5.x <?php class crypto_class { function encrypt($string,$password) { $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $password, $iv); $encrypted = mcrypt_generic ($td, $string); mcrypt_generic_end ($td); return($encrypted); } // end encrypt function decrypt($encrypted,$password) { $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $password, $iv); $decrypted = mdecrypt_generic ($td, $encrypted); mcrypt_generic_end ($td); return($decrypted); } //end decrypt } // end crypto_class $crypto = new crypto_class; $encrypted = $crypto->encrypt('passwordx','good2Go123'); $decrypted = $crypto->decrypt($encrypted,'good2Go123'); print "$encrypted<br>\n"; print "$decrypted<br>\n"; ?>

« previous php.notes (#47113) next »