Welcome Guest, Not a member yet? Register   Sign In
Difficulty using BCrypt!
#1

Hi,

I am trying to use bcrypt and I know that the hash is always different when the bcrypt is used, but I am told that I should get the hashed password from the database, and use the non hashed password from the login form, use some method magic, and hey, it should work, right?

I won't paste all the code, just sections that are for the password.

Well, for me that isn't the case and I was wondering if you can take a look my code below. Also its not complete, some things you will see just to test.

LOGIN
PHP Code:
$sql "SELECT * FROM user WHERE email = '".$this->email."'";
 
           $query $this->db->query($sql);
 
           if ($query) {
 
               foreach ($query->result() as $row) {
 
                   echo $this->password "<br>";
 
                   echo $row->password "<br>";
 
                   var_dump(password_verify($this->password$row->password));
 
                   if(password_verify($this->password$row->password)) {
 
                       echo 'The password is correct';
 
                       exit();
 
                   
 
               }
 
           
 
           else {
 
               echo 'query failed!';
 
           }
 
        


REGISTER
PHP Code:
$this->password password_hash($this->passwordPASSWORD_DEFAULT, ['cost' => 15]); 

My return is always false. Is this looking correct and there is something wrong on my part, or am I generally just not doing this right.
Reply


Messages In This Thread
Difficulty using BCrypt! - by dreamweaver - 07-05-2019, 01:11 PM
RE: Difficulty using BCrypt! - by dreamweaver - 07-05-2019, 01:40 PM
RE: Difficulty using BCrypt! - by jreklund - 07-05-2019, 11:11 PM
RE: Difficulty using BCrypt! - by dreamweaver - 07-06-2019, 07:50 AM
RE: Difficulty using BCrypt! - by InsiteFX - 07-06-2019, 08:12 AM
RE: Difficulty using BCrypt! - by arbkami - 03-27-2020, 01:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB