Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

sha1 Password Hashing

  • 24-08-2007 05:42PM
    #1
    Registered Users, Registered Users 2 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