note 61209 added to function.md5
| From: | vozz at osu1 dot php dot net | Date: | Sat, 28 Jan 2006 08:20:01 +0000 |
| Subject: | note 61209 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-102601@lists.php.net to get a copy of this message | ||
A really simple way to make the hash more confusing to decipher (if someone was trying to brute
force it, for example) you could do a bunch of things. Here I rot13 the inputted string
('str'), then SHA-1 it, then md5 it and compare it to the thing stored in the database
(which is rot13'd, sha'd and md5'd). The table we are using is passwords and the
password is of course, password.
<?php
//defines the variable where we are going to query
$userPassword = sprintf("SELECT vozz FROM passwords");
//preform query
$userPasswordQuery = mysql_query($userPassword);
//start the cypher process
$userPasswordRot13 = str_rot13($_POST['str']);
$userPasswordSha = sha1($userPasswordRot13);
$userPasswordMd5 = md5($userPasswordSha);
//Check to see if it matches
if($userPasswordMd5==$UserPasswordQuery){
echo("Logging in...");
}else{
echo("Invalid Password, please go back and retry.");
}
?>
As you can see, it is a really simple method, you could store all of your passwords in plain text
and then do the entire rot13 sha1 md5 stuff but that would be a pain and a security flaw at the same
time.
The entire reason this works is that it will output a 40 char string if the md5 hash is cracked, and
that string will be cyphered in SHA-1 so they will have to crack it again, but then it will be
ROT13'd but that's easy to get around. It would take a lot more time to crack it then it
would with just a normal md5 hash, I mean, it would probably take over 200 years to crack a 40 char
hash on a normal desktop system, unless there is a collision.
----
Server IP: 64.71.164.2
Probable Submitter: 66.234.223.95
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61209
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61209&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61209&report=yes
Search -- http://master.php.net/manage/user-notes.php