I know that true randomness only exists in nature.  However, the
randomization in PHP is fairly good. I have only used it on fairly small
scales (i.e. Randomizing 200 quotes to give a random quote when people log
onto a page.) 

For passwords I have always gone an easier route.

$password = time();

This will produce an impossible to guess string of numbers I think about 9
or 10 characters in length.

I am sure others here will have better options.  But this has worked well
for me and is very very easy.



<?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?>

> From: "J. Connolly" <[EMAIL PROTECTED]>
> Date: Tue, 08 Mar 2005 14:41:11 -0500
> To: PHP list <php-db@lists.php.net>
> Subject: [PHP-DB] Random Password problem
> 
> I am using this php in order to create, store and send random passwords
> to people who want to join my mailing list.
> 
> <?php
> function random_password () {
> $seed = (integer) md5(microtime());
> mt_srand($seed);
> $password = mt_rand(1,99999999);
> $password = substr(md5($password), 3,9);
> return $password;
> }
> ?>
> 
> <?php
> $msg = random_password();
> echo $msg;
> ?>
> 
> I seem to be getting the same number very often which makes me fear that
> this is not so random. I am a noob so I do not know if this is
> coincidence or a fault in my coding.
> Right now, I have been setting up passwords manually, but would like
> users to be as free from me as possible. Any direction would be helpful.
> 
> BTW, I keep getting the following number an absurd amount of times. I
> have deleted cookies and even gone to other machines, and yet it still
> generates this number.
> 
> 8f31a3
> 
> Thank you,
> jozef
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to