phpass-0.3 problems |
[eluser]giovannidc[/eluser]
I'm trying to use phpass-0.3 to hash my users' passwords but I've ran into some trouble trying to implement it into Codeigniter. Here is what I have done: I extracted the phpass library to "libraries/phpass-0.3" My model looks like: Code: class User_model extends CI_Model { When I run this code I get four errors: Quote:A PHP Error was encountered Quote:A PHP Error was encountered Quote:A PHP Error was encountered Quote:A PHP Error was encountered :question:I also then get my output: Quote:The hashed password of mypassword is: $P$BJzL2yyPw6IeahYqndDsslcnRJFlDS0 So any ideas on how to get rid of the errors would be great
[eluser]giovannidc[/eluser]
I got it working at last. Here is what I did: In my libraries folder I still have the phpass-0.3 folder that contains PasswordHash.php I created a new file called Phpass.php and placed it in my libraries folder: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); My model,user_model.php looks like: Code: <?php I don't really understand why this makes a difference, but it worked for me!
[eluser]jellysandwich[/eluser]
The problem is this: Code: // Setup phpass When you use $this->load->library, Codeigniter will automatically attempt to instantiate an instance of the object and set it to $this->{library name}. Unfortunately, it's not smart enough to pass in the two required variables to the constructor, which is why you're getting those errors.
[eluser]Unknown[/eluser]
After doing some home work I decided to rewrite the PasswordHash function by adding the following lines of code to the beginning of the function: Code: function PasswordHash($params = array()) Reference Link: http://stackoverflow.com/questions/91419...odeigniter Works great for me Making use of it: Code: $this->load->library('passwordhash', array('iteration_count_log2' => 8, 'portable_hashes' => FALSE ));
[eluser]Aken[/eluser]
You could also create a config file with those params in an array that would automatically be included when the library was loaded.
[eluser]brock[/eluser]
i'm kind of at a loss for why the native CI library class for Encryption can't be used 'out of the box' for securely storing passwords for use in login/registration |
Welcome Guest, Not a member yet? Register Sign In |