I've seen a few other post on this, and it sounds like there is more then one of use that is trying this script. I've got it so that I can use the commands, but I still get errors on the page...
here is what I have done. I downloaded libmycrpt from ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt and configured it with the following options; ./configure \ --with-included-algos="rijndael-128 arcfour stream cbc cfb"\ --disable-posix-threads I then reconfigured php with the --with-mcrpty option. now when I try to run the code I get the following errors; (the php code I will repost inc ase there are any questions) Usage Warning: key size is 0 in /usr/local/apache/htdocs/test.phtml on line 15 Warning: mcrypt_generic_init: Key length incorrect in /usr/local/apache/htdocs/test.phtml on line 15 Warning: mcrypt_generic(): 1 is not a valid MCrypt resource in /usr/local/apache/htdocs/test.phtml on line 16 Warning: mcrypt_generic_deinit(): 1 is not a valid MCrypt resource in /usr/local/apache/htdocs/test.phtml on line 17 encrypted = Warning: key size is 0 in /usr/local/apache/htdocs/test.phtml on line 25 Warning: mcrypt_generic_init: Key length incorrect in /usr/local/apache/htdocs/test.phtml on line 25 Warning: mdecrypt_generic(): 2 is not a valid MCrypt resource in /usr/local/apache/htdocs/test.phtml on line 26 Warning: mcrypt_generic_deinit(): 2 is not a valid MCrypt resource in /usr/local/apache/htdocs/test.phtml on line 29 decrypted = Oops they don't match <?PHP class encrypt_decrypt { var $secret; function encrypt_class(){ $this->secret = 'this is a very long key, even too long for the cipher'; } Function encode($id){ $eid = $iv = 0; $len = strlen($id); $id = $len.'-'.$id; $td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $key = substr($this->secret, 0, mcrypt_enc_get_key_size ($td)); $iv = pack("a".mcrypt_enc_get_iv_size($td),$iv); mcrypt_generic_init ($td, $key, $iv); $eid = base64_encode(mcrypt_generic ($td, $id)); mcrypt_generic_deinit($td); return $eid; } Function decode($eid){ $id = $iv = 0; $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $key = substr($this->secret, 0, mcrypt_enc_get_key_size ($td)); $iv = pack("a".mcrypt_enc_get_iv_size($td),$iv); mcrypt_generic_init ($td, $key, $iv); $id = mdecrypt_generic ($td, base64_decode($eid)); $len = strtok($id,'-'); $id = substr($id,(strlen($len)+1),$len); mcrypt_generic_deinit($td); return $id; } } ?> Usage <? $word = 'Hello'; $e = new encrypt_decrypt(); $encrypted = $e->encode($word); echo "encrypted = $encrypted <br>"; $decrypted = $e->decode($encrypted); echo "decrypted = $decrypted <br>"; if($word == $decrypted){ echo "They match <br>"; } else{ echo "Oops they don't match <br>"; } ?> -- Jeff Bluemel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php