28, May 2012

Login: SHA1/MD5 passwords don't match - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: Login: SHA1/MD5 passwords don't match
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: Login: SHA1/MD5 passwords don't match  (Read 2504 times)
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« on: Feb 24, 2011, 08:05:01 pm »

I'm trying to create a User Login on my website using php/mySQL. When I create a new user, I send the password as a MD5 hash to my database. The problem is, when I try to login with the same password (again, hashed using MD5), the passwords don't match.

Here is my SQL code:
for createUser.php:
Code:
INSERT INTO `Users` (`UserLogin`, `UserPass`)
VALUES ('name', MD5('pwd'))

for login.php
Code:
SELECT *
FROM `Users`
WHERE `UserLogin` = 'name' AND `UserPass` = MD5('pwd')

I have tried entering this code directly into phpMyAdmin, with no results -- so it isn't a problem with my php code. I have also tried using SHA1 hashing.

What am I doing wrong?
Bill Cosby is my Father
*
Posts: 4
28 credits
Members referred : 0


« Reply #1 on: Feb 27, 2011, 12:40:54 pm »

Hi,

the only reason I can imagine is that the `UserPass` column is not big enough to hold the hash.

For example if the is hash is 1234 but your column can only hold 123, the next time you'll compare the generated hash 1234 with 123 it won't match.

If changing that doesn't help, post your table structure.

Destructive
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« Reply #2 on: Feb 27, 2011, 02:33:30 pm »

Quote
the only reason I can imagine is that the `UserPass` column is not big enough to hold the hash

Thanks, Destructive! That was exactly it. My UserPass was set as INT(16), and needed to be at least INT(32) to hold the hashed password.
Bill Cosby is my Father
*
Posts: 4
28 credits
Members referred : 0


« Reply #3 on: Feb 27, 2011, 02:46:49 pm »

You're welcome. I'm glad I could help you.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=11365
Tags : sql MD5 sha1 encryption login Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  Php User Class
Topic: Login: SHA1/MD5 passwords don't match
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 03:21:26 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 62.814
Total Topics: 11.028
Total Members: 21.451
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: sobbin

138 Guests, 3 Users online :

11 users online today:




Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.