0

Here's my error:

Fatal error: Call to undefined function password_hash() in /Applications/mampstack-5.4.25-1/apache2/htdocs/php-login/application/models/login_model.php on line 462

PHP line 462:

$user_password_hash = password_hash($_POST['user_password_new'], PASSWORD_DEFAULT, array('cost' => $hash_cost_factor));

I'm aware that password_hash is PHP 5.5.0 and I am using it. I've tried playing around with it but could succeeded. Any help would be great.

EDIT:

It says mampstack-5.4.25-1 but that's simply a name for it. I've upgraded. I've used PHP 5.5.0 features just this morning.

7
  • 2
    What?!?! You have PHP 5.4.24! That is not 5.5.0! Commented Mar 11, 2014 at 20:21
  • 2
    Use the Userland implementation by ircmaxell: github.com/ircmaxell/password_compat Commented Mar 11, 2014 at 20:22
  • How would that be? I used PHP 5.5.0 features on other projects earlier today. @AbraCadaver Commented Mar 11, 2014 at 20:24
  • Dunno, but: 5.4.25-1 /apache2/htdocs/php-login/application/models/login_model.php on line 462 Commented Mar 11, 2014 at 20:26
  • What PHP5.5 feature did you use? Are you sure it is PHP5.5 only? Commented Mar 11, 2014 at 20:27

1 Answer 1

0

as for your php version you could use this

$salt = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
$passh = crypt($pass, '$6$'.$salt);

$6$ means that its SHA-512 just remember to store salt in database, so you can check the password afterwards.

Sign up to request clarification or add additional context in comments.

1 Comment

Your call to crypt() will return $6$salt$hash, you don't have to store the salt separately. Also, mcrypt_create_iv() returns a binary string that may not store well. substr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), 0, 16); will generate a random, 7-bit safe salt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.