md5 question

This is a discussion on md5 question within the PHP Language forums, part of the PHP Programming Forums category; I am having problems with using md5 with a password. I am able to set the password with the md5 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-12-2003
entoone
 
Posts: n/a
Default md5 question

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,




Reply With Quote
  #2 (permalink)  
Old 08-12-2003
Louis-Philippe Huberdeau
 
Posts: n/a
Default Re: md5 question

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,
>
>
>
>


Reply With Quote
  #3 (permalink)  
Old 08-12-2003
MeerKat
 
Posts: n/a
Default Re: md5 question

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

Reply With Quote
  #4 (permalink)  
Old 08-12-2003
entoone
 
Posts: n/a
Default Re: md5 question

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" <lphuberdeau@sympatico.ca> wrote in message
news:el%Za.6498$Z03.341723@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,
> >
> >
> >
> >

>



Reply With Quote
  #5 (permalink)  
Old 08-12-2003
Phil Roberts
 
Posts: n/a
Default Re: md5 question

With total disregard for any kind of safety measures "entoone"
<entoone@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.....
Reply With Quote
  #6 (permalink)  
Old 08-13-2003
entoone
 
Posts: n/a
Default Re: md5 question

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" <philrob@HOLYflatnetSHIT.net> wrote in message
news:Xns93D5EAA07F429philroberts@216.196.97.132...
> With total disregard for any kind of safety measures "entoone"
> <entoone@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.....



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:31 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0