Welcome Guest, Not a member yet? Register   Sign In
Can I compare CI encrypt data with encrypted data in the database, like with md5?
#1

[eluser]Robert May[/eluser]
I'm working on an authentication system. With md5, you encrypt the submitted password and check it against the stored encrypted password.
Using the CI encrypt class, can I do the same? Or do I have to retrieve the password and decode it before comparing?
#2

[eluser]davidbehler[/eluser]
Try something like this:
Quote:$hash = $this->db->escape(dohash('i_am_the_submitted_password', 'md5'));
$query = "select * from table where password_hash_column = $hash";

That should work
#3

[eluser]Murodese[/eluser]
You can use sha1() or $this->encrypt->sha1(), which are one-way hashing functions. Of course, you can still use md5 but it's starting to show holes these days.

You should also be salting the passwords, but I'll leave you to read up on that.




Theme © iAndrew 2016 - Forum software by © MyBB