Zend - The PHP Company




Passwords

Add Code


A Simple Random Password Generation Function  

Type: code fragment
Added by: funcent
Entered: 06/01/2005
Last modified: 01/12/2004
Rating: - (fewer than 3 votes)
Views: 7215
A simple random password generation function which generates various length (up to 32 characters) of password with numerals and alphabets.


<?php
function genPass($length 8//max length = 32 characters
{
 return 
substr(md5(uniqid(rand(), true)), 0$length);
}
?>


Usage Example


<?php
echo genPass(); //default length = 8 characters

echo "nn<br><br>nn";

echo 
genPass(12); //length = 12 characters
?>


Rate This Script





Search



This Category All Categories