NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP / mySQL encryption weirdness. Has anybody ever seen this?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-10-2007, 11:58 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



PHP / mySQL encryption weirdness. Has anybody ever seen this?


I always seem to run into weird problems. Has anybody ever experienced something like this?

Setup:
I am encrypting passwords with the mysql ENCODE function, then storing them in a tinyblob field in a mysql database.

I have a test user set up with the userid of "demo1" and a password of "demo1". I was testing the change password with the encryption that I wrote. The code is straight forward:

Here is the function in the encryption class that I have:

Code:
function encrypt() {
   $sql = "select encode('" . addslashes($this->getdec()) . "', '" . $this->getsalt() . "');";
   $encryptResult = mysql_query($sql);
   $encryptRow = mysql_fetch_array($encryptResult);
   $this->setenc($encryptRow[0]);
} # end encrypt()
The code that I am using to set the password looks like this:

Code:
$c = new customer($id);
$e = new encryption($p1,'e');
$c->setpassword($e->getenc());
$res = $c->updateCustomer();
$id is the customer id
$p1 is merely the password

Now, the strangeness comes when I try to set the password to 'demo1'. It ALWAYS sets it to 'demo'. The trailing '1' gets chopped off. I can change the password to ANYTHING else that I want (for example, 'demo0', demo2', and 'test1' all work just fine).

Further, if I alter the value of the salt, I can change the password to 'demo1' without any issues.

I know the seemingly easy answer is to just change the salt. However, it begs the question, "If this happened with the combination of the original salt and the password 'demo1', will the new salt produce any weird combinations that will not take in the database too?"
????: NamePros.com http://www.namepros.com/programming/360142-php-mysql-encryption-weirdness-has-anybody.html

Has anybody ever run into this problem? How did you solve it?
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:45 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger