Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10

Thread: crypt()

  1. #1
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    I was wondering, say while a person signs up, I encrypt whatever he/she inserts and I insert it into mysql, now I was fooling around with this function in my browser, and for the same value of $password when it encrypts what i enter for password, when I refresh it always changes around now. If I wish to retreive the encrypted password from the database and check how would I do this, if it changes each of the time?

    for ex:
    PHP Code:
    $result mysql_query_first("SELECT password FROM user WHERE username='$username'");

    if (
    crypt($inputpassword) == $result[password]) {
       echo 
    "Password Correct"
    }else{
       echo 
    "Password inCorrect"

    Arunan S.
    CEO/President
    ServerLines, LLC.

  2.  

  3. #2
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    Wow...I just noticed how to make it work
    Thanks for anyone who took the time to look at it
    Arunan S.
    CEO/President
    ServerLines, LLC.

  4. #3
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    Do you think if I changed
    PHP Code:
    if (crypt($inputpassword) == $result[password]) { 
    to
    PHP Code:
    if (crypt($inputpassword,$result[password]) == $result[password]) { 
    That should work?
    Arunan S.
    CEO/President
    ServerLines, LLC.

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Off-topic: you should be using $result['password'] instead of $result[password]; PHP will think password is a constant otherwise.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    But how would it work? It doesn't seem to work both ways.

    if (crypt($inputpassword,$result['password'])

    Does the $result['password'] change the encryption of the inputed password so it equals the value of $result['password'] (from the database)

    So this would work right?
    Arunan S.
    CEO/President
    ServerLines, LLC.

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    If the type of hashing doesn't matter, then just use this instead:
    Code:
    UPDATE user SET password = MD5('whatever') WHERE userid = 1
    and
    Code:
    $password = md5("whatever");
    SELECT password FROM user WHERE userid = 1
    if (the query's result == $password)...
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    $password on the second one being the person entering it say into a form?
    Arunan S.
    CEO/President
    ServerLines, LLC.

  9. #8
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Right, the unhashed version.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  10. #9
    Senior Member Arunan's Avatar
    Join Date
    Jan 2003
    Location
    Toronto, Ontario
    Posts
    139
    Member #
    478
    Umm I will check it out

    Thanks
    Arunan S.
    CEO/President
    ServerLines, LLC.

  11. #10
    Member
    Join Date
    Oct 2002
    Posts
    52
    Member #
    224
    If you want to do it like vB w/ MD5 then when checking the password of the user logging in use
    $password = md5($password);
    and then validate it against the query result.
    -Andy Zmudosky


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:40 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com