Tuesday, 13 August 2013

Integrate password_compat library

Integrate password_compat library

This is not my first time using CodeIgniter or Bcrypt, but it is my first
time using a specific library of Bcrypt with CodeIgniter. I am having
issue integrating thee two together.
Lets get to the code :
public function create_user($value) {
$this -> CI = get_instance(); // Get the CI instance
$this -> CI -> load -> library('bcrypt'); // Use this to load the
library from within the model
$hash = $this -> CI -> bcrypt ->
password_hash($value[":password"], PASSWORD_BCRYPT, array("cost"
=> 17)); Here is where things get shaky.
$value[":password"] = $hash; // Here I take the :password
placeholder and update the clear text password with the bcrypt
pasword
var_dump($value[":password"]); // This gives me NULL, I assume
because I am getting errors with $hash = .......
........................................
as per manual with Password_compat :
BCRYPT also allows for you to define a cost parameter in the options
array. This allows for you to change the CPU cost of the algorithm:
$hash = password_hash($password, PASSWORD_BCRYPT, array("cost" => 10));
On my front end these are the errors I keep getting :
Message: Use of undefined constant PASSWORD_BCRYPT - assumed
'PASSWORD_BCRYPT'
Message: password_hash() expects parameter 2 to be long, string given
any help would be great. Thank you.

No comments:

Post a Comment