This code is for Generate the system generated Password.

<?php

$password=”your password”;

echo “Password is :”.$password.”<br>”;
$ran=rand();
//echo $ran;
$salt = sha1($ran);

//echo “<br>”.$salt;
$salt = substr($salt, 0, 10);

//echo “<br>”.$salt.”<br>”;

$encrypted = base64_encode(sha1($password . $salt, true) . $salt);

//echo “Encrypted Password is :”.$encrypted;

$hash = array(“salt” => $salt, “encrypted” => $encrypted);

//Store in Database
$saltt=$hash[‘salt’];
echo $saltt;
$passwordt=$hash[‘encrypted’];
echo “<br>”.$passwordt;

$hash = base64_encode(sha1($password . $saltt, true) . $saltt);
if($hash==$passwordt)
{
echo “<br>Yes match found”;
}
else
{
echo “<br>Not found”;
}

// $uuid = uniqid(”, true);
//echo “<br>”.$uuid;

?>

Advertisements