![]() |
Having trouble with md5()
I am having trouble understanding the md5() function. Can anyone explain it a little and explain how to implement it into my login script?
|
The
md5() function simply returns a hash of the string that you feed into it. The MD5 hash is usually a 32 character hexadecimal number (a string containing only 0-9 and a-f characters). For an in-depth look at what MD5 does, take a look at the MD5 Wikipedia page but don't get too bogged down in the details as that may confuse you even more. |
With
md5() you can hash your password. md5 isn't reversible, so you can't reverse the hash back to the original password. Ofcourse there are big databases where you can check a md5 hash against, but when you're also salting the password this won't work.I feel like md5 together with a salt is generally safe enough to store your passwords. Read more about salts here: http://www.talkphp.com/tips-tricks/1...phy-salts.html. So, basically you only have to do: PHP Code:
|
Quote:
In the same case, when a user registers, you make an MD5 hash of his password like this: Code:
if (isset($_POST['submit']))In example: the hash of the single letter a is : 0cc175b9c0f1b6a831c399e269772661 and the hash of a similar string, aa is: 4124bc0a9335c27f086f24ba207a4912 Quite different, even though the inputs are similar. Now, here is part 2! We have the MD5 hash of the user's password stored, which is not the actual password. In theory, there should be only one phrase in the entire world which equals the hash, and that is greendog32. So, here is what the login script would look like: Code:
if(isset($_POST['submit'])) |
Quote:
|
Well explained, Dog Cow. Another encryption method that is similar to MD5, just longer and of course a different algorithm, is SHA1, which is inherent to PHP using the
sha1() function. The principle is exactly the same as MD5. |
Which would be the best way to secure the login?
|
That's quite simple to answer:
http://www.talkphp.com/general/2226-md5-sha1.html You could also use a salt, to make it harder to reverse, read it up here: http://www.talkphp.com/tips-tricks/1...-chloride.html |
| All times are GMT. The time now is 04:13 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0