note 70258 deleted from function.md5 by joey

From: Date: Sun, 17 Jul 2011 08:41:49 +0000
Subject: note 70258 deleted from function.md5 by joey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181611@lists.php.net to get a copy of this message
Note Submitter: maximius at gmail dot com ---- 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!

« previous php.notes (#181611) next »