By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

md5 question

P: n/a
I am having problems with using md5 with a password.

I am able to set the password with the md5 coverting what I type into say..
"a87ff679a2f3e71"

I'm writing to the db with the password and the condition by using

-------- pword=md5('$ud_pword')

I am having a problem reading the value from the db after it's set. I use a
form that wants an id and the password to load the record for editing, when
I type "a87ff679a2f3e71" into the form It loads, when I type the password
that I typed in the form that made coverted to "a87ff679a2f3e71" it
doesn't work.

So the password is entered, saved in the db as "a87ff679a2f3e71"

and now I want to relogin with the standard password, without having to type
"a87ff679a2f3e71"
I'm attempting to read the password in my query as follows.

$query="SELECT * FROM contacts WHERE (notid=$serid) and
pword=md5('$serpass')";
*** I altered this query so much, that I'm not sure what I have tired and
not tried, as always I appreciate your efforts and assistance on my many
questions.

Thanks! in advance,


Jul 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
The md5 algorithm generates a 32 characters hash. Make sure your
database field can contain those 32 characters, otherwise, it will be
truncated.

entoone wrote:
I am having problems with using md5 with a password.

I am able to set the password with the md5 coverting what I type into say..
"a87ff679a2f3e71"

I'm writing to the db with the password and the condition by using

-------- pword=md5('$ud_pword')

I am having a problem reading the value from the db after it's set. I use a
form that wants an id and the password to load the record for editing, when
I type "a87ff679a2f3e71" into the form It loads, when I type the password
that I typed in the form that made coverted to "a87ff679a2f3e71" it
doesn't work.

So the password is entered, saved in the db as "a87ff679a2f3e71"

and now I want to relogin with the standard password, without having to type
"a87ff679a2f3e71"
I'm attempting to read the password in my query as follows.

$query="SELECT * FROM contacts WHERE (notid=$serid) and
pword=md5('$serpass')";
*** I altered this query so much, that I'm not sure what I have tired and
not tried, as always I appreciate your efforts and assistance on my many
questions.

Thanks! in advance,


Jul 16 '05 #2

P: n/a
entoone wrote:
I am having problems with using md5 with a password.

I am able to set the password with the md5 coverting what I type into say..
"a87ff679a2f3e71"


This doesn't seem to be long enough for a MySQL MD5 - it should be 32
hex characters. Check that the field is long enough.

MK.

--
MeerKat

Jul 16 '05 #3

P: n/a
I did adjust the field from 15 to 32, and then I edited my coding again and
it seemed to work.

I did have to login, change my password, for testing purposes just to the
single character of "4", which made my password the super long string of
characters. I then attempted to re-login in using the 4 as the password and
it let me in.

I did another test with an account that had a password of say "cat", but
when I typed in cat into the password box, it didn't log me in, since I
think it wants all passwords that are currently in the db to be in this
"hash" format right?

1. Do I need to covert the other account passwords? or ??
2. I have an option on the page after you login to allow password changes,
when you see the password it's the
scrambled "hash" version, and not the "4" how can they see their password as
they would understand and not the other version?

Thanks again

"Louis-Philippe Huberdeau" <lp*********@sympatico.ca> wrote in message
news:el*******************@news20.bellglobal.com.. .
The md5 algorithm generates a 32 characters hash. Make sure your
database field can contain those 32 characters, otherwise, it will be
truncated.

entoone wrote:
I am having problems with using md5 with a password.

I am able to set the password with the md5 coverting what I type into say.. "a87ff679a2f3e71"

I'm writing to the db with the password and the condition by using

-------- pword=md5('$ud_pword')

I am having a problem reading the value from the db after it's set. I use a form that wants an id and the password to load the record for editing, when I type "a87ff679a2f3e71" into the form It loads, when I type the password that I typed in the form that made coverted to "a87ff679a2f3e71" it
doesn't work.

So the password is entered, saved in the db as "a87ff679a2f3e71"

and now I want to relogin with the standard password, without having to type "a87ff679a2f3e71"
I'm attempting to read the password in my query as follows.

$query="SELECT * FROM contacts WHERE (notid=$serid) and
pword=md5('$serpass')";
*** I altered this query so much, that I'm not sure what I have tired and not tried, as always I appreciate your efforts and assistance on my many
questions.

Thanks! in advance,

Jul 16 '05 #4

P: n/a
With total disregard for any kind of safety measures "entoone"
<en*****@pacbell.net> leapt forth and uttered:
$query="SELECT * FROM contacts4 WHERE (notid=$serid) and
(pword='$serpass')";


$query="SELECT * FROM contacts4 WHERE notid=$serid and pword=MD5('$serpass')";
--
There is no signature.....
Jul 16 '05 #5

P: n/a
Very good Phil! that works... Thanks for your time.

I am able to read the value from the db now, without having to use clear
text! -- Bravo!

Now onto a script to be able to change the passwords.

"Phil Roberts" <ph*****@HOLYflatnetSHIT.net> wrote in message
news:Xn*************************@216.196.97.132...
With total disregard for any kind of safety measures "entoone"
<en*****@pacbell.net> leapt forth and uttered:
$query="SELECT * FROM contacts4 WHERE (notid=$serid) and
(pword='$serpass')";

$query="SELECT * FROM contacts4 WHERE notid=$serid and

pword=MD5('$serpass')";

--
There is no signature.....

Jul 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.