Welcome Guest, Not a member yet? Register   Sign In
Understanding hash_password_db() - Ion Auth
#1

[eluser]anna16[/eluser]
Hi guys

Just wondering what does the salt column mean in users table
in these codes below,

Code:
public function hash_password_db($identity, $password)
{
    if (empty($identity) || empty($password))
    {
    return FALSE;
    }

    $query = $this->db->select('password')
        ->select('salt')
        ->where($this->identity_column, $identity)
        ->where($this->ion_auth->_extra_where)
        ->limit(1)
        ->get($this->tables['users']);

     $result = $query->row();

     if ($query->num_rows() !== 1)
     {
    return FALSE;
     }

     if ($this->store_salt)
     {
    return sha1($password . $result->salt);
     }
     else
     {
    $salt = substr($result->password, 0, $this->salt_length);

    return $salt . substr(sha1($salt . $password), 0, -$this->salt_length);
     }
}

Anyone familiar?

Thanks in advanced.
#2

[eluser]InsiteFX[/eluser]
Hi anna,

ION Auth uses the salt to protect the password stronger.

Makes it harder for someone to decrypt the password.

InsiteFX
#3

[eluser]anna16[/eluser]
thanks insite.
#4

[eluser]anna16[/eluser]
Hi

insiteFX

what is _extra_where in this code select mean?
Is this a variable? cuz i don't see it in the code as a variable?


Code:
$query = $this->db->select('password')
                 ->select('salt')
                 ->where($this->identity_column, $identity)
                 ->where($this->ion_auth->_extra_where)
                 ->limit(1)
                 ->get($this->tables['users']);
#5

[eluser]InsiteFX[/eluser]
Hi anna,

Code:
/**
* extra_where
*
* Crazy function that allows extra where field to be used for user fetching/unique checking etc.
* Basically this allows users to be unique based on one other thing than the identifier which is helpful
* for sites using multiple domains on a single database.
*
* @return void
* @author Phil Sturgeon
**/
public function extra_where()
{
    $where =& func_get_args();

    $this->_extra_where = count($where) == 1 ? $where[0] : array($where[0] => $where[1]);
}

InsiteFX
#6

[eluser]anna16[/eluser]
So it's a function.

I did not saw it immediately cuz I'm dizzy.
I guess I need a break. XD Smile
#7

[eluser]anna16[/eluser]
WoW extra_where() is cool...

By the way i noticed when the code is pointing like this,

Code:
->_extra_where

It append the underscore in the beginning of the extra_where method.
What is underscore do?

Thanks
#8

[eluser]anna16[/eluser]
Okay i saw it now.
It's the variable in ION Auth.
Sigh, I'm no patience. XD Smile




Theme © iAndrew 2016 - Forum software by © MyBB