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
I made this into a library itself so I put it into application/librarys folder
any help would be great. Thank you.
Okay well looking at this file (which was my old Bcrypt.php file)
You notice I do not have these lines added :
if (!defined('PASSWORD_DEFAULT')) {
define('PASSWORD_BCRYPT', 1);
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
Well the reason I removed them was because I had put the above snippet of code under the Class Bcrpyt { ... line which would cause an error.
Now I put this snippet code :
if (!defined('PASSWORD_DEFAULT')) {
define('PASSWORD_BCRYPT', 1);
define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
Class Bcrypt {
This is all I had to do for it to work. Silly me! Now it works :
string(60) "$2y$17$9qgFDbN3361DAQFilGZySuJ4czachQThuskoSj4DihkxjwGFqTx2e"