Too Cool for Internet Explorer


Swobodin's Profile | Swobodin's Blog | Back to Fedora Tunisia

Random password generator

Here’s a quick PHP function to generate a random password, usage:
genrand($password_length);
<?php
 
function genrand($len = 10) {
for ($i = 0; $i < 26; $i++) {
$str[$i] = chr($i+65);
}
unset($i);
for ($i = 26; $i < 52; $i++) {
$str[$i] = chr($i+71);
 
}
 
unset($i);
for ($i = 52; $i < 62; $i++) {
$str[$i] = $i-52;
}
unset($i);
mt_srand(microtime()*100000);
 
$retval = NULL;
for ($i = 1; $i <= $len; $i++) {
$random = mt_rand(0, count($str)-1);
$retval .= $str[$random];
 
}
unset($i);
return $retval;
}
 
?>

Related posts

(sometimes, the plugin foolishes)
Lack of security in OpenSource?
Starting Sudoku
Chess is confusing me
Murphy programming laws
Snipper

Technorati tags

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

 
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a


Top Tunisie Blogs