Jump to content

SHA512 hashing creates a 500 error


Faracus

Recommended Posts

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

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

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 by Faracus
Link to comment
Share on other sites

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 by Faracus
Link to comment
Share on other sites

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

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 by Faracus
Link to comment
Share on other sites

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

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 by Faracus
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
×
×
  • Create New...