Hi, I figured it out.
$_SESSION['iv_size'] = mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_NOFB); $_SESSION['iv'] = mcrypt_create_iv($_SESSION['iv_size'], MCRYPT_DEV_URANDOM); Issue: I could not get return what was put in mcrypt, with exacting results. Some strings would encrypt, but when decrypted the string would be different by a few characters or not even close to the original. I was calling mcrypt_create_iv() more than once from page to page on the site. Since mcrypt_create_iv uses a random component, the output would be different thus giving different results on the decrypt since the same mcrypt_create_iv was not used as in the encrypt. It was an implementation issue. Do not call mcrypt_create_iv in every script that needs to encrypt or decrypt data. mcrypt_create_iv should only be called once and stored in a session var or cookie if you plan to make use of it in other scripts on your site. If anyone have more input? Please comment. Sincerely, Mike -- Mike Brandonisio * Web Hosting Tech One Illustration * Internet Marketing tel (630) 759-9283 * e-Commerce [EMAIL PROTECTED] * http://www.jikometrix.net JIKOmetrix - Reliable web hosting On Feb 8, 2006, at 8:11 PM, Mike Brandonisio wrote: > Hi, > > I should also add that I'm using sessions. > > Sincerely, > Mike > -- > Mike Brandonisio * Web Hosting > Tech One Illustration * Internet Marketing > tel (630) 759-9283 * e-Commerce > [EMAIL PROTECTED] * http://www.jikometrix.net > > JIKOmetrix - Reliable web hosting > > > On Feb 8, 2006, at 7:58 PM, Mike Brandonisio wrote: > >> Hi, >> >> Has anyone here worked with mcrypt? I'm having trouble getting >> predicable results. >> >> Example if I use 3DES and MCRYPT_MODE_ECB I cannot encrypt "157058" >> and then decrypt it and get the same thing. The 8 is obscured as >> someother character. >> >> Example if I use 3DES and MCRYPT_MODE_NFO I cannot encrypt >> "poiuy789" and then decrypt it and get the same thing. The 789 is >> obscured as other characters. >> >> My key and connect string are both 16 character. >> >> Any Ideas. I am trying to create a login that encrypts the id and PW >> in a cookie so I can decryp and compare it to a record entry. The >> client wants the PW in plain text in the DB. >> >> Sincerely, >> Mike >> -- >> Mike Brandonisio * Web Hosting >> Tech One Illustration * Internet Marketing >> tel (630) 759-9283 * e-Commerce >> [EMAIL PROTECTED] * http://www.jikometrix.net >> >> JIKOmetrix - Reliable web hosting >> >> >> >> >> Community email addresses: >> Post message: [email protected] >> Subscribe: [EMAIL PROTECTED] >> Unsubscribe: [EMAIL PROTECTED] >> List owner: [EMAIL PROTECTED] >> >> Shortcut URL to this page: >> http://groups.yahoo.com/group/php-list >> Yahoo! Groups Links >> >> >> >> >> >> >> >> >> > > > > Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > > Shortcut URL to this page: > http://groups.yahoo.com/group/php-list > Yahoo! Groups Links > > > > > > > > Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
