[PHP] random letters and numbers

2001-04-24 Thread Randy Johnson

Is there a way to generate a random set of characters ranging from 8 to 12
characters and numbers where it is crucial that the letters and numbers are
truly random because I need to create temporary files for people to download
information.

Any links/suggestions would be greatly appreciated

Thanks

Randy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] random letters and numbers

2001-04-24 Thread Steve Lawson

Sup,
I made this and have been using it for about 6 months without problem.
mt_rand() is 4 times faster than normal rand(), remember to use mt_srand()
to seed.  The 8 in the while controls how long the $password will be...


$count = 0;

mt_srand( (double) microtime() * 100);

while( $count  8 )
{
   $randval = mt_rand(48 , 122);
   $timeout++;

   // currently allows 0-9 and a-z (lowercase), add 65-90 for uppercase
   if(($randval  47  $randval  58) || ($randval  96  $randval  123))
   {
  $password .= chr($randval);
  $count++;
   }
}

SL.


- Original Message -
From: Randy Johnson [EMAIL PROTECTED]
Cc: Php-General [EMAIL PROTECTED]
Sent: Tuesday, April 24, 2001 12:10 AM
Subject: [PHP] random letters and numbers


 Is there a way to generate a random set of characters ranging from 8 to 12
 characters and numbers where it is crucial that the letters and numbers
are
 truly random because I need to create temporary files for people to
download
 information.

 Any links/suggestions would be greatly appreciated

 Thanks

 Randy


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] random letters and numbers

2001-04-24 Thread J. Jones

On Mon, Apr 23, 2001 at 11:10:48PM -0700, Randy Johnson wrote:
 Is there a way to generate a random set of characters ranging from 8 to 12
 characters and numbers where it is crucial that the letters and numbers are
 truly random because I need to create temporary files for people to download
 information.
 
 Any links/suggestions would be greatly appreciated
 
 Thanks
 
 Randy
 

Also check out the tempnam() and tmpfile() functions, as this is exactly
what they were made for ;)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] random letters and numbers

2001-03-24 Thread Randy Johnson

Is there an easy way to create random numbers and letters for a file example


http://www.mydomain.com/1w2e3rff.txt  

and then after they download it have it be deleted off the server?


thanks

randy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] random letters and numbers

2001-03-24 Thread Pierre-Yves Lemaire

Hello,

I use a random password function to do just that,

function randomPassword($length = 8) {
   // all the chars we want to use
   $all = explode( " ",
 "a b c d e f g h i j k l m n o p q r s t u v w x y z "
 . "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
 . "0 1 2 3 4 5 6 7 8 9 _");

for($i=0;$i$length;$i++) {
  srand((double)microtime()*100);
  $randy = rand(0, 61);
  $pass .= $all[$randy];
}

 return $pass;
}

$new_filename = randomPassword(10);


For the delete of the file, unlink is your answer:
http://www.php.net/manual/en/function.unlink.php

hope it help!
py

At 12:05 PM 3/24/01 -0500, you wrote:
Is there an easy way to create random numbers and letters for a file example


http://www.mydomain.com/1w2e3rff.txt

and then after they download it have it be deleted off the server?


thanks

randy

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


+ ==
+ Pierre-Yves Lem@ire
+ E-MedHosting.com
+ (514) 729-8100
+ [EMAIL PROTECTED]
+ ==


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] random letters and numbers

2001-03-24 Thread Joe Stump

Sure - use md5()

--Joe

On Sat, Mar 24, 2001 at 12:05:49PM -0500, Randy Johnson wrote:
 Is there an easy way to create random numbers and letters for a file example
 
 
 http://www.mydomain.com/1w2e3rff.txt  
 
 and then after they download it have it be deleted off the server?
 
 
 thanks
 
 randy
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
/*\
 *Joe Stump  *
 *www.Care2.com  *   
 *Office: 650.328.0198   *
 *Extension: 122 *
\*/
www.miester.org

-BEGIN GEEK CODE BLOCK-
Version: 3.12 
GB/E/IT d- s++:++ a? C UL++$ P+ L+++$ E! W+++$
N+@ o? K? w---! O-@ M+@ V-! P(++) PE(+) Y+@ PGP+++@ t+@
5? R-! tv@ b+ DI++@ D() G++@ e+@ h@ r+! z(+**)!
--END GEEK CODE BLOCK--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]