I wanna save hashed password in mysql database,so I develop following method in CodeIgniter.
private function hashing($password = '',$mail = '')
{
$hashcode = md5($password, $mail);
return sha1($hashcode,md5($hashcode.$mail));
}
for insert:
$data = array('mail'=>$mail,'password'=>$password,'actived'=>1,'time'=>time());
$this->db->insert('users', $data);
other field inserted correctly instead password.
it will generate something like
òLmyÉZÔe+ú§3GèÇu‘
it can’t be saved in mysql database.where is the problem?
edit database Collation is utf8_unicode_ci
edit I’m using CodeIgniter,so it doesn’t need mysql_real_…
You probably meant to do this:
Instead of this:
The second argument to
sha1()is a boolean value, controlling whether it returns the hash in raw or string format (false = string, which is what you want to insert).http://php.net/manual/en/function.sha1.php