just my 2 cents. Easy way to hash passes.
function hashPassword($pass, $salt=FALSE) {
// The following will put the $salt at the begining, middle, and end of the password.
// A little extra salt never hurt.
if (!empty($salt)) $pass = $salt . implode($salt, str_split($pass, floor(strlen($pass)/2))) . $salt;
return md5( $pass );
}
Then simply do something like:
function addUser($username, $password) {
$password = $this->hashPassword($password, $username);
$dataIns = array(
'username' => $username
, 'password' => $password
);
if ($this->db->insert('users', $dataIns)) return $this->db->insert_id();
return FALSE;
}
And later:
function attemptLogin($username, $password) {
$query = $this->db->get_where('peeps', array('peepsname' => $username, 'password' => $this->hashPassword($password, $username)));
if ($query->num_rows() == 1) {
$user = $query->result_array()[0];
$sess = $this->setSession($user);
return $user;
}
return FALSE;