views:

59

answers:

1

Alright, so I tried to make my users info super secure by adding '" . sha1($_POST['password']) . "' when inserting their password when they register. THAT WORKS great, looking at the database, I have no clue what their password is.

Now the problem is logging in. I'm running some tests and when I try to log in, the password 12345 doesn't match the encrypted password using "$password=sha1($_POST['mypassword']);"

Any idea's why?

+2  A: 

Double check the size of the password column on your database... ensure that it's holding the entire sha1 hash. (varchar(40))

When hashing the password, what is the value of the raw_output parameter? If true, then your return is a 20-character binary string; if false, it's a 40-character ASCII string. Ensure you can store a binary value on the database if the former, or change to using the latter.

Mark Baker
Mark you are 100% correct, the length was at 32. thanks@dmazzoni, I'm researching salt now. It's a full time job staying up with all this stuff.
Jason
Have a look at Josh K's answer to http://stackoverflow.com/questions/3038136/am-i-supposed-to-store-hashes-for-passwords about salting.... it's a nice simple worked example
Mark Baker