Re: [PHP] recent encrpyt decrypt code... (problems)
Never mind that! I found the answer when I did the Google search. It said mHash come first, then libmcrypt then mcrypt. So, that's what it should be. Yea, it can also be libmcrypt 1st then mhash then mcrypt. I got what I need to know which is that libmcrypt should come before mcrypt. So, it fit with what Tom Rogers said. "Scott Fletcher" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > You got to be kidding me I use similar code and a sample of yours and I > got just about the same error message as what Jeff Bluemel got. I checked > the PHP Info and it showed that I had the libmcrypt accepted but no > supported ciphers. Then I posted two seperate unanswered posting until I > stumpled onto this. > > I did not understand why mcrypt is required along with the libmcrypt. > Libmcrypt is just an combination of mcrypt and extra stuffs. The url, > php.net/mcrypt said to use libmcrypt and it mentioned of no mcrypt. So, it > was no wonder I had problem. Now I know I did not ask the right question in > the PHP newsgroup. I am glad to see a solution to this problem. Thank you > for the responses and your solution to the problem as it help with Jeff > Bluemel, it now helped me too. Thank you! > > FletchSOD > > P.S. Do I compile mcrypt before libmcrypt or is it the other way around? > > "Tom Rogers" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hi, > > > > Friday, October 4, 2002, 3:01:53 PM, you wrote: > > JB> I've seen a few other post on this, and it sounds like there is more > then > > JB> one of use that is trying this script. I've got it so that I can use > the > > JB> commands, but I still get errors on the page... > > > > JB> here is what I have done. > > > > JB> I downloaded libmycrpt from > > JB> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt and configured it > with > > JB> the following options; > > > > JB> ./configure \ > > JB> --with-included-algos="rijndael-128 arcfour stream cbc cfb"\ > > JB> --disable-posix-threads > > > > That is a class I put together. I use libmcrypt-2.5.2 configured with: > > > > configure --prefix=/usr --enable-ltdl-install=no > > > > and mcrypt-2.6.2 configured with: > > > > configure --prefix=/usr > > > > and in php configure: > > > > --with-mcrypt=/usr/src/mcrypt-2.6.2 (thats where it was untarred) > > > > and it works like a dream :) > > > > -- > > regards, > > Tom > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] recent encrpyt decrypt code... (problems)
You got to be kidding me I use similar code and a sample of yours and I got just about the same error message as what Jeff Bluemel got. I checked the PHP Info and it showed that I had the libmcrypt accepted but no supported ciphers. Then I posted two seperate unanswered posting until I stumpled onto this. I did not understand why mcrypt is required along with the libmcrypt. Libmcrypt is just an combination of mcrypt and extra stuffs. The url, php.net/mcrypt said to use libmcrypt and it mentioned of no mcrypt. So, it was no wonder I had problem. Now I know I did not ask the right question in the PHP newsgroup. I am glad to see a solution to this problem. Thank you for the responses and your solution to the problem as it help with Jeff Bluemel, it now helped me too. Thank you! FletchSOD P.S. Do I compile mcrypt before libmcrypt or is it the other way around? "Tom Rogers" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > Friday, October 4, 2002, 3:01:53 PM, you wrote: > JB> I've seen a few other post on this, and it sounds like there is more then > JB> one of use that is trying this script. I've got it so that I can use the > JB> commands, but I still get errors on the page... > > JB> here is what I have done. > > JB> I downloaded libmycrpt from > JB> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt and configured it with > JB> the following options; > > JB> ./configure \ > JB> --with-included-algos="rijndael-128 arcfour stream cbc cfb"\ > JB> --disable-posix-threads > > That is a class I put together. I use libmcrypt-2.5.2 configured with: > > configure --prefix=/usr --enable-ltdl-install=no > > and mcrypt-2.6.2 configured with: > > configure --prefix=/usr > > and in php configure: > > --with-mcrypt=/usr/src/mcrypt-2.6.2 (thats where it was untarred) > > and it works like a dream :) > > -- > regards, > Tom > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] recent encrpyt decrypt code... (problems)
ok Tom - that worked... thanks for your help and assistance... I never would have figured this out without the help. Jeff "Tom Rogers" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > Sunday, October 6, 2002, 7:32:11 AM, you wrote: > JB> ok - that made things work... here is the output. it looks like it is > JB> still encrypting it. what would the resolution be for this, or can I set > JB> the key to anything I want? > > Ok I have got to the bottom of it :) > You changed the name of the class but did not change the name of the > constructor so the key was never getting set. > So change > class encrypt_decrypt > { > var $secret; > function encrypt_class(){ > $this->secret = 'this is a very long key, even too long for the cipher'; > } > > to: > class encrypt_decrypt{ > var $secret; > function encrypt_decrypt(){ > $this->secret = 'this is a very long key, even too long for the cipher'; > > } > > > > > -- > regards, > Tom > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] recent encrpyt decrypt code... (problems)
Hi, Sunday, October 6, 2002, 7:32:11 AM, you wrote: JB> ok - that made things work... here is the output. it looks like it is JB> still encrypting it. what would the resolution be for this, or can I set JB> the key to anything I want? Ok I have got to the bottom of it :) You changed the name of the class but did not change the name of the constructor so the key was never getting set. So change class encrypt_decrypt { var $secret; function encrypt_class(){ $this->secret = 'this is a very long key, even too long for the cipher'; } to: class encrypt_decrypt{ var $secret; function encrypt_decrypt(){ $this->secret = 'this is a very long key, even too long for the cipher'; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] recent encrpyt decrypt code... (problems)
Hi, Sunday, October 6, 2002, 4:20:40 AM, you wrote: JB> here is the URL that will give you the php compile info on my website JB> (phpinfo) Looks identical to mine as far as mcrypt is concerned. Try changing the $key = to this: $key = 'test'; As it looks like the key is getting truncated to 0 -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] recent encrpyt decrypt code... (problems)
Hi, Saturday, October 5, 2002, 4:10:03 AM, you wrote: JB> I had not downloaded mcrypt, but I download it (which required a later JB> version of mhash so I downloaded, and installed it too). I compiled JB> everything with the instrucitons you listed, and I am still getttng the same JB> error messages. I just recompiled using the latest versions of libmcrypt - mcrypt - mhash and it still works ok. I don't use dynamic loading of php it is built into apache statically. What version of PHP/apache are you using? .. I use 4.2.3 -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] recent encrpyt decrypt code... (problems)
I had not downloaded mcrypt, but I download it (which required a later version of mhash so I downloaded, and installed it too). I compiled everything with the instrucitons you listed, and I am still getttng the same error messages. Jeff "Tom Rogers" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > Friday, October 4, 2002, 3:01:53 PM, you wrote: > JB> I've seen a few other post on this, and it sounds like there is more then > JB> one of use that is trying this script. I've got it so that I can use the > JB> commands, but I still get errors on the page... > > JB> here is what I have done. > > JB> I downloaded libmycrpt from > JB> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt and configured it with > JB> the following options; > > JB> ./configure \ > JB> --with-included-algos="rijndael-128 arcfour stream cbc cfb"\ > JB> --disable-posix-threads > > That is a class I put together. I use libmcrypt-2.5.2 configured with: > > configure --prefix=/usr --enable-ltdl-install=no > > and mcrypt-2.6.2 configured with: > > configure --prefix=/usr > > and in php configure: > > --with-mcrypt=/usr/src/mcrypt-2.6.2 (thats where it was untarred) > > and it works like a dream :) > > -- > regards, > Tom > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] recent encrpyt decrypt code... (problems)
Hi, Friday, October 4, 2002, 3:01:53 PM, you wrote: JB> I've seen a few other post on this, and it sounds like there is more then JB> one of use that is trying this script. I've got it so that I can use the JB> commands, but I still get errors on the page... JB> here is what I have done. JB> I downloaded libmycrpt from JB> ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt and configured it with JB> the following options; JB> ./configure \ JB> --with-included-algos="rijndael-128 arcfour stream cbc cfb"\ JB> --disable-posix-threads That is a class I put together. I use libmcrypt-2.5.2 configured with: configure --prefix=/usr --enable-ltdl-install=no and mcrypt-2.6.2 configured with: configure --prefix=/usr and in php configure: --with-mcrypt=/usr/src/mcrypt-2.6.2 (thats where it was untarred) and it works like a dream :) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] recent encrpyt decrypt code... (problems)
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 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 encode($word); echo "encrypted = $encrypted "; $decrypted = $e->decode($encrypted); echo "decrypted = $decrypted "; if($word == $decrypted){ echo "They match "; } else{ echo "Oops they don't match "; } ?> -- Jeff Bluemel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php