As already mentioned, you cannot decrypt MD5 without attempting something like hacking brute force, which is extremely resource-intensive, impractical and unethical.
However, you can use something like this to safely encrypt / decrypt / etc passwords:
$input = "SmackFactory"; $encrypted = encryptIt( $input ); $decrypted = decryptIt( $encrypted ); echo $encrypted . '<br />' . $decrypted; function encryptIt( $q ) { $cryptKey = 'qJB0rGtIn5UB1xG03efyCp'; $qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) ); return( $qEncoded ); } function decryptIt( $q ) { $cryptKey = 'qJB0rGtIn5UB1xG03efyCp'; $qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0"); return( $qDecoded ); }
Using the encypted salt method would be even safer, but that would be a good next step after using the MD5 hash.
BIT CHEETAH Mar 04 '13 at 5:02 2013-03-04 05:02
source share