Faracus Posted August 11, 2012 Share Posted August 11, 2012 When I try and hash passwords on my site using SHA512 it goes straight in to a 500 error, but as soon as I take the hash out, then it loads properly. $encpassword = hash(sha512($password.$salt)); that is the line of code that is causing the problem. I'm running the web server off my computer for development, I have Apache 2.2.22 with PHP 5.3.14. I've tryed a google search, but SHA512 is a popular checksum for downloads so I get a lot of hits with that. Link to comment Share on other sites More sharing options...
boen_robot Posted August 11, 2012 Share Posted August 11, 2012 Last I checked, there's no "sha512" function in PHP, so that's why you get 500. Calling an undefined function is a fatal error, and your server is configured to display a 500 error page on fatal errors.To be sure (or to make debugging of similar issues easier), you'd have to enable error logging at some location of your choice, and check them next time you see the 500 error page. Link to comment Share on other sites More sharing options...
Faracus Posted August 12, 2012 Author Share Posted August 12, 2012 (edited) As of PHP 5.3.2 SHA512 has been supported natively with the PHP libraries. It looks like I have to upgrade my PHP, thanks for the point in the right direction. I thought it was a mod in apache that I needed, not PHP itself. After looking I do have SHA512, but I am still getting the 500 error, and after looking in my error logs there is nothing there about it. I've updated my hash code to:$encpassword = hash("sha512",$password.$salt); Edited August 12, 2012 by Faracus Link to comment Share on other sites More sharing options...
boen_robot Posted August 12, 2012 Share Posted August 12, 2012 SHA-512 is supported, but not with a sha512() function. It's supported with the crypt() and hash() functions. Link to comment Share on other sites More sharing options...
Faracus Posted August 12, 2012 Author Share Posted August 12, 2012 (edited) which is why I updated the code to $encpassword = hash("sha512",$password.$salt); I'll try the crypt function. *EDIT* After switching my code to $encpassword = crypt ($password, '$6$rounds=5000$'$salt); I am still getting the error 500 with still nothing showing in my error logs. Edited August 12, 2012 by Faracus Link to comment Share on other sites More sharing options...
boen_robot Posted August 12, 2012 Share Posted August 12, 2012 You're missing a dot around before the "$" in '$6$rounds=5000$'$salt If you don't see anything in the logs, this can only mean you either haven't configured it, or haven't specified error_reporting to "E_ALL" in php.ini. Link to comment Share on other sites More sharing options...
Faracus Posted August 12, 2012 Author Share Posted August 12, 2012 (edited) it was set to E_ALL, but display errors was set to off, now after turning them on I get a Parse error: syntax error, unexpected T_VARIABLE pointing to the link of my cyrpt, Ihave fixed the . before the salt but it's still giving me this error $encpassword = crypt($password, '$6$rounds=5000$'.$salt); Edited August 12, 2012 by Faracus Link to comment Share on other sites More sharing options...
birbal Posted August 13, 2012 Share Posted August 13, 2012 what is the previous line of it? if syntax error pointing to that line,that does not always mean problem occured in that line, it could be in previous line (like missed semicolon) Link to comment Share on other sites More sharing options...
Faracus Posted August 13, 2012 Author Share Posted August 13, 2012 (edited) thanks for that, it was a semi-colon from the previous line. But now I'm getting an error saying that the 64 character database table is not long enough for the final password, how long is it going to be? Edited August 13, 2012 by Faracus Link to comment Share on other sites More sharing options...
justsomeguy Posted August 13, 2012 Share Posted August 13, 2012 SHA-512 produces a 512-bit hash, which is 64 bytes, but if you don't know how the crypt function works then print the output or at least look at the manual page for it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now