Just want to use PHPass in Codeigniter to hash the password. I downloaded the zip file from phpass website, extracted the content, and copied the PasswordHash.php file into my libraries folder.
Then I loaded that library in my controller and tried to hash password but it gave following errors
Missing argument 1 for PasswordHash::PasswordHash(), called in ...
Missing argument 2 for PasswordHash::PasswordHash(), called in ...
Undefined variable: iteration_count_log2 ...
Undefined variable: portable_hashes ...
Please check my controller code below and help me to find the mistake:
$this->load->library('PasswordHash');
$password = $this->input->post('password');
$hash = $this->passwordhash->HashPassword( $password );
Here's how i do it. first create it as a helper.
to use the phpass helper, load the helper, instantiate it, call HashPassword function:
in config/constants.php add the following code:
You should also now understand why you getting the error about missing argument 1 and 2. When you instantiate the PasswordHash class you need to supply two arguments to it. You can create phpass as a CodeIgniter Library file too. Just change the function PasswordHash to __constructor and when calling the library supply two arguments. i'll leave you to figure that out.