Jump to content

php hash


gsmith
 Share

Recommended Posts

Is there a version of php and older that doesn't have the hash() function in it?I'm trying to hash passwords using:$pssword=hash('sha1','$_POST["password"]');But it says I'm calling an undefined function when I run it. There's PHP version 4.3.8 on the server I'm working with.

Link to comment
Share on other sites

Strange line to put in the documentation for hash(),

(no version information, might be only in CVS)
?might? :) At least your options have better version info:sha1(), md5()What I can tell you is that I'm using 4.3.7 on XP and md5() and sha1() both work.The hash() does not.You'll want to remove the single quotes : $pssword = sha1('$_POST["password"]');Good Luck,
Link to comment
Share on other sites

Ok, I used sha1 as the function instead of hash - and it worked.Now I'm having trouble logging on though. Am I correct that if I sha1() the same word/phrase/etc. I'll get the same hexadecimal output every time? I hope that's correct, because then I'm on the right track...I'm also frustrated becuase I don't understand why what I've done isn't working! :)

Link to comment
Share on other sites

Maybe something about your test of values.You could throw in some 'echo' statements for debuggin'.

<?phpif(isset($_POST['pw'])) {  $user = 'gsmith';  $topsecret = "wwwdot";    if($_POST['user'] == $user && sha1($_POST['pw']) == sha1($topsecret))      echo "passed";      else      echo "failed";}?><form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">    User: <input type="text" name="user" value="gsmith"><br>    Password: <input type="text" name="pw" value="wwwdot"><br>    <input type="submit"></form>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...