- chr: documentation ( source)
- rand: documentation ( source)
- md5: documentation ( source)
<?php
//generate salt----------------------------------->
$salt;
$password = "texmex";
for ($i=0; $i<=32; $i++) {
$d=rand(1,30)%2;
$salt .= $d ? chr(rand(65,90)) : chr(rand(48,57));
}
//end generate salt--------------------------------|
//hash password with salt-->
$hashed = md5($password . $salt);
//here is your new encrypted password, ready to store in the database table, `jos_users`
echo $encrypted = $hashed . ':' . $salt;