note 70258 added to function.md5
| From: | maximius at gmail dot com | Date: | Mon, 09 Oct 2006 05:38:00 +0000 |
| Subject: | note 70258 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118233@lists.php.net to get a copy of this message | ||
This is just something I made while looking into MD5 and SHA-1, how they can be exploited, and
whatnot.
/**
* crypto - Generates a hash made up of 40 letters and digits
* by passing a source variable through a custom algorithm.
* First it determines the CRC32, customizable crypt, and MD5
* hashes for the source variable, and implodes them into one
* string. This string can be seperated by another customizable
* salt variable. Finally the SHA-1 hash of the original source
* variable is calculated, with the imploded string appended
* to the end of the source variable.
*/
function crypto($source){
$salt[0] = "something here!"; // Limit this to 16 characters
$salt[1] = "abcd"; // Limit this to 8 characters
$crypt[0] = crc32($source);
$crypt[1] = crypt($source, $salt[0]);
$crypt[2] = md5($source);
$crypt = implode($salt[1], $crypt);
return sha1($source.$crypt);
}
It works really well if you need a secure, custom hashing function. I hope it works for whatever you
use it for!
----
Server IP: 66.207.199.35
Probable Submitter: 70.66.98.187
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- https://master.php.net/note/edit/70258
Del: integrated -- https://master.php.net/note/delete/70258/integrated
Del: useless -- https://master.php.net/note/delete/70258/useless
Del: bad code -- https://master.php.net/note/delete/70258/bad+code
Del: spam -- https://master.php.net/note/delete/70258/spam
Del: non-english -- https://master.php.net/note/delete/70258/non-english
Del: in docs -- https://master.php.net/note/delete/70258/in+docs
Del: other reasons-- https://master.php.net/note/delete/70258
Reject -- https://master.php.net/note/reject/70258
Search -- https://master.php.net/manage/user-notes.php