I was working on the new membership project. And when I looking at the database design there is a password_salt field , which is VARCHAR(20). In my previous project I just encrypt the password with md5, it is not secure .
$save['password'] = md5($this->input->post('password'));
I found some code to generate a salt , it seems to be just generate a random string, but what is the suitable size, is it sufficient to use VARCHAR(20)?
protected function _create_salt()
{
$this->CI->load->helper('string');
return sha1(random_string('alnum', 20));
}
Also, It would be highly appreciate if there is code example of
1) using salt to validate
2) using salt to hash the password so that it can save to database
Thanks.