<?php
/*
This class creates random password with alphanumeric values, and its md5 value can be stored in database. Generally useful in cases like when a user forgets his password.
*/
class PassMd5
{
private $password;
public function create($pass)
{
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
$pass = '';
for($i=0;$i<12;$i++)
{
$pass .= substr($str,rand(0,62),1);
}
$this->password=$pass;
return $this->password;
}
} // end of class
// example of how to use
$newpass=new PassMd5();
echo "New password = ".$newpass->create($pass);
echo "<br>(md5) of New password = ".md5($newpass->create($pass));
?>
Output:
/*
This class creates random password with alphanumeric values, and its md5 value can be stored in database. Generally useful in cases like when a user forgets his password.
*/
class PassMd5
{
private $password;
public function create($pass)
{
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
$pass = '';
for($i=0;$i<12;$i++)
{
$pass .= substr($str,rand(0,62),1);
}
$this->password=$pass;
return $this->password;
}
} // end of class
// example of how to use
$newpass=new PassMd5();
echo "New password = ".$newpass->create($pass);
echo "<br>(md5) of New password = ".md5($newpass->create($pass));
?>
Output:
Comments
Post a Comment