Password hashing before save |
HI , how can i hash the password before save ? I use the ci function $model->save() (without parameter)
You can use password_hash - PASSWORD_BCRYPT. For example, on registration you can send the password to the DB :
PHP Code: $model->save( On Login : First retrieve the password from db. For example keep it under a name "$hashed_one". Then either receive what the user types : PHP Code: $admin_password = $this->request->getVar('admin_password'); And (or receive what the user types here) in the final step: Match them PHP Code: if(password_verify($this->request->getVar('admin_password'),$hashed_one)){ |
Welcome Guest, Not a member yet? Register Sign In |