Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

sha1 Password Hashing

Options
  • 24-08-2007 5:42pm
    #1
    Registered Users Posts: 7,041 ✭✭✭


    Can somebody explain to me how to use sha1() because it doesn't appear to be working very well for me. Do you get the sha1() of your password and store that in the database?

    I'm getting locked out of the page I'm trying to secure because it keeps telling my I have the wrong password.

    [PHP]
    $pass_1 = strip_tags($_POST);
    $password = mysql_real_escape_string($pass_1);
    $password_Secured = sha1($password);[/PHP]

    Also it won't echo the $password for me. It echos everything else but $password.

    Thanks,
    S.


Comments

  • Closed Accounts Posts: 89 ✭✭constellation


    I'm guessing that is PHP. Never used it but is this any use? (Have a look at second comment down).

    http://ie2.php.net/sha1


  • Closed Accounts Posts: 365 ✭✭ronanp


    If its just a login ya want, store the sha1 of the password in the database, then compare the sha1 of the POST password to the database version for authentication.

    Insert operation:

    [php]
    $insert_user = "insert into users (username,password) values ('$username', sha1('$password'))";
    [/php]

    Retrieve using a query like:

    [php]
    $password=$_POST;
    $query=mysql_query("SELECT * FROM users WHERE username = '$username' AND password = sha1('$password')");
    [/php]


Advertisement