Welcome Guest, Not a member yet? Register   Sign In
Login check verifies wrong
#1

[eluser]InterCoder[/eluser]
Hey all,

I've got this code:

Code:
$result = $this->login_model->get_LoginInfo($this->input->post('email'));

if(!$result) {
    $error = true;
    echo 'error place 2';
    $this->session->set_flashdata('login', 'Dit account bestaat niet.');
} else {
    echo sha1('some key'.'some hash'.sha1('something'));
    $password = sha1($this->config->item('salt').$result['hash'].sha1($this->input->post('password')));
    echo $password;
    if($password == $result['password']) {
        $this->session->set_userdate(array('id' => $result['id']));
        echo 'Ingelogd';
    } else {
        $error = true;
        echo 'error place 3';
        $this->session->set_flashdata('login', 'De account gegevens komen niet overeen.');
    }
}

Now I'm always getting "error place 3". The first echo (in the first else clause) returns an other hash than the $password. But in the first echo I'm putting the values manually and in $password I'm loading them in. Every bit of $password is correct: $this->config->item('salt'), $result['hash'] and $this->input->post('password') give the correct value individually.

The check $password == $result['password'] always fails. In other words: The first echo (with manually input) differs from the $password hash (with automatically input).

Any tips?

Regards,
InterCoder
#2

[eluser]InterCoder[/eluser]
Ok, Now I know it's because of $this->config->item('salt'). If I replace it with the actual value of this config item, it returns the correct hash. But if I echo this config item, it also gives me the actual value. How can I use it correctly which I was intended to do? Even when I do:

Code:
$salt = $this->config->item('salt');
and put $salt in the $password sha1() it returns an other hash value Sad

Edit: Sorry for the bump!

Edit: Fixed it, apparently the salt key got malformed when processed. I had as salt key:
}XVD{l|{T[?"1hU?,DW18;no,CR:p$?/@)j$?cE<PEb/?5w>+$"i{"]Mw{%1Gc(
it turned in:
}XVD{l|{T[?"1hU?,DW18;no,CR:p$?/@)j$?cE+$"i{"]Mw{%1Gc(

Thanks anyway XD




Theme © iAndrew 2016 - Forum software by © MyBB