Cannot check hashed password

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Cannot check hashed password

    Hello,

    When users enter their email address and password in the login form, a login
    check is made using the following code. (The password is hashed in the database)

    <!--- Find record with this Email/password --->
    <cfquery name="getUser" datasource="security">
    SELECT email, password
    FROM users
    WHERE email = '#FORM.email#' AND password = '#form.password#'
    </cfquery>

    <cfoutput>
    <cfif Hash(Form.password, "SHA") is not getUser.password>
    Not working
    <cfelse>
    OK, it works.
    </cfif>
    </cfoutput>

    I cannot get it to return "OK , it works" for the life of me. Can anyone point
    out what's incorrect?

    Many thanks,
    Bob

    bob2cam Guest

  2. Similar Questions and Discussions

    1. How to check a PDF document contain password security?
      Are there anyway to check it for OLE automation? I want to test whether the document is editable. Dont't tell me that I need to try edit or insert...
    2. How do I can check a password Hash in WSE 2.0
      By example Client token = new UsernameToken("juan", "1111", PasswordOption.TextPlain ); Server protected override string...
    3. Check HASH Password in WSE 2.0. Please Help.
      By example, the next code work well. Client token = new UsernameToken("juan", "1111", PasswordOption.TextPlain ); Server protected override...
    4. MD5 System Password check with PHP
      Hello everybody, I want to authenticate my user from web with PHP script. The user's passwords are stored in System as MD5 format (in...
    5. Is Cookies hashed by default
      If I stored some data in a cookie, does ASP.NET hash the values in cookies by default to prevent the data from being tempered? If ASP.NET does...
  3. #2

    Default Re: Cannot check hashed password

    Because the password field in your database is hased and the form field you are
    passing into the getUser query is not, that query will return 0 results.

    You have two options:

    - Have your WHERE clauase contain only the email address and not the password
    and then do your compare with the CFIF statement
    - Create a variable that is a hash of the form password and use that in your
    query WHERE clause, then change your conditional statement to see if
    getUser.RecordCount is 0

    TA-Selene Guest

  4. #3

    Default Re: Cannot check hashed password

    Selene is correct, you need to hash form.password before using it as a query
    criteria. Or don't include the password as criteria but compare it afterwards,
    but I don't see any advantage to doing that. I use hashed passwords in a lot of
    apps, and do something like below.



    <cfset HashedPW = Hash(form.password)>

    <cfquery name="getUser" datasource="security">
    SELECT email, password
    FROM users
    WHERE email = '#FORM.email#' AND password = '#HashedPW#'
    </cfquery>

    mkane1 Guest

  5. #4

    Default Re: Cannot check hashed password

    Thank you both. It works great!

    Bob
    bob2cam Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139