Tuesday, November 22, 2011

Generating MD5 Encrypted Password For Storing In Database


This code block generates hash code for an input such as password. But this must be kept in mind that this uses MD5 encryption method,which is only one way encryption method. Means if u want to decrypt the stored password in database it is not feasible. So you can also use reset passord method for setting new password:-

[This code is written in php,butt this can be used in any other desired language using the same function.]


function get_hash(){
$string = '0123456789abcdefghijklmnopqrstuvyxz';
$hash = '';
for ($i = 0; $i < 5; $i++){
$rand = rand(0, (34 - $i));
$hash .= $string[$rand];
$string = str_replace($string[$rand], '', $string);
}
return $hash;
}

No comments:

Post a Comment