[eluser]GamingFusion[/eluser]
ok im having a problem with my sha1 encryption.
when i user register the password is encrypted as usual.
when the user logs in it is encrypted also but the encryptions are different for example the password
123456789 on register gives f7c3bc1d808e04732adf
and this on login f7c3bc1d808e04732adf679965ccc34ca7ae3441
why?
heres my code
register
Code:
function register()
{
$this->load->library('encrypt');
$first = $this->input->post('first');
$last = $this->input->post('last');
$username = $this->input->post('username');
$password = $this->input->post('password');
$passconf = $this->input->post('passconf');
$confirm = $this->input->post('confirm');
$encryptpass = $this->encrypt->sha1($password);
$data = array('first' => $first, 'last' => $last, 'username' => $username, 'password' => $encryptpass);
$query = $this->db->insert('users', $data);
if ($query) {
return $data['register'] = TRUE;
}else{
return $data['register'] = FALSE;
}
}
login
Code:
function login()
{
$this->load->library('encrypt');
$this->load->helper('cookie');
$username = $this->input->post('username');
$password = $this->input->post('password');
$encryptpass = $this->encrypt->sha1($password);
$checkUser = $this->db->get_where('users', array('username' => $username, 'password' => $encryptpass));
if ($checkUser->num_rows() < 1) {
echo 'Password is incorrect.<br>';
echo $password, '<br>';
echo $encryptpass;
}else{
$usernme = array(
'name' => 'username',
'value' => $username,
'expire' => '86500',
'domain' => '.localhost:8888',
'path' => '/',
'prefix' => 'myprefix_',
);
$passwrd = array(
'name' => 'password',
'value' => $encryptpass,
'expire' => '86500',
'domain' => '.localhost:8888',
'path' => '/',
'prefix' => 'myprefix_',
);
set_cookie($usernme);
set_cookie($passwrd);
redirect('theater', 'refresh');
}
}
the login function returns
this on failure
Quote:Password is incorrect.
123456789
f7c3bc1d808e04732adf679965ccc34ca7ae3441