CodeIgniter Forums
i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format (/showthread.php?tid=43803)



i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format - El Forum - 07-24-2011

[eluser]Alpha[/eluser]
i want my password to be md5 using the codes posted below, after execution i checked db content and its not in md5 format, is there something i missed? tnx

$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');

$this->db->query("INSERT INTO users (email, password) VALUES ('".$this->input->post('email')."', '".$this->input->post('password')."')");


i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format - El Forum - 07-24-2011

[eluser]jzmwebdevelopement[/eluser]
[quote author="anthar" date="1311511809"]i want my password to be md5 using the codes posted below, after execution i checked db content and its not in md5 format, is there something i missed? tnx

$this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');

$this->db->query("INSERT INTO users (email, password) VALUES ('".$this->input->post('email')."', '".$this->input->post('password')."')");[/quote]

Yes:

Have a read here: http://ellislab.com/codeigniter/user-guide/helpers/security_helper.html


i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format - El Forum - 07-24-2011

[eluser]Aken[/eluser]
It's also not recommended to use md5() to encrypt passwords: http://www.php.net/manual/en/faq.passwords.php#faq.passwords.fasthash


i want my password to be md5 using the codes posted, after execution i checked db content and its not in md5 format - El Forum - 07-24-2011

[eluser]InsiteFX[/eluser]
You need to hash and encrypt the password before you send it to the database!
When checking the entered password you need to do the same when checking it from the database.
Code:
// --------------------------------------------------------------------

    /**
     * _hash_password()
     *
     * Hashs and encrypts the users password using the set
         * config encryption key.
     *
     * @access    private
     * @param    string    - $password
     * @return    string
     */
    private function _hash_password($password)
    {
        return sha1($password . $this->config->item('encryption_key'));
    }

InsiteFX