RE: [PHP] Password Generator Script

2002-07-27 Thread Naintara Jain

The following code was created to generate a random password.
But it can be used to generate a random string for any purpose.

The basic idea was to create an array that would contain all the letters of
the English alphabet, and pick out random values from that array. I have
outlined two methods below, please also read the explanation/comments
provided below.

Method 1:
$strrandom=””;

$ivalfrom =ord("a");
$ivalto =ord("z");

for($i=$ivalfrom; $i<=$ivalto; $i++)
$arralpha[] = chr($i);

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

$rand_al = array_rand ($arralpha, 3);
$strrandom = $arralpha[$rand_al[0]] . $arralpha[$rand_al[1]] .
$arralpha[$rand_al[3]];
$numpart=mt_rand(10,99);
$strrandom .= $numpart;

echo "random = $strrandom";


-

Method 2:
$strrandom=””;

$ivalfrom =ord("a");
$ivalto =ord("z");

for($i=$ivalfrom; $i<=$ivalto; $i++)
$arralpha[] = chr($i);

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

$strrandom =
$arralpha[mt_rand(0,25)].$arralpha[mt_rand(0,25)].$arralpha[mt_rand(0,25)];
$numpart=mt_rand(10,99);
$strrandom .= $numpart;

echo "random = $strrandom";

-

Explanantion:

/* I used a “for” loop to populate the array with the alphabets in lowercase
(to increase the number of values, you could probably insert uppercase
alphabets too). */

//first populate array with alphabets
$ivalfrom =ord("a");
$ivalto =ord("z");

//add the alphabets to the array
for($i=$ivalfrom; $i<=$ivalto; $i++)
$arralpha[] = chr($i);

/* $arralpha is an array variable which refers to the array of 26 alphabets.
*/

/* I seed the random generator */
mt_srand ((double) microtime() * 100);

/* I wanted my string to contain 3 random letters. I use the array_rand()
function, which takes as input an array, and the number of random values
desired (which is 3 here, but it could be 26 too, equal to or less than the
size of the array). It returns an array, which contains indexes taken at
random from the array passed as the argument.*/

$rand_al = array_rand ($arralpha, 3);
/* Here, $rand_al is another array variable which contains random indexes */

$strrandom=””;
$strrandom = $arralpha[$rand_al[0]] . $arralpha[$rand_al[1]] .
$arralpha[$rand_al[3]];
/* In the above statement, the values in the $rand_al are really subscripts
of the alphabet array, so I use them as subscripts to finally arrive at the
random string. You could iterate through the generated $rand_al using a loop
to get the subscripts */

/* Please note that array_rand() will work for PHP4 and above, it may not
return random values if you do not seed the generator first, and it may
still create a problem on some windows machines (a bug, which has been fixed
on PHP 4.2.2 –dev version). In such a case, use Method 2. */

/* The two lines below add a 2-digit number to the random string. */
$numpart=mt_rand(10,99);
$strrandom .= $numpart;

-Naintara


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
t]On Behalf Of Liam MacKenzie
Sent: Thursday, July 25, 2002 1:04 PM
To: [EMAIL PROTECTED]; Monty
Subject: Re: [PHP] Password Generator Script




Random Password : 


In action:
http://scripts.operationenigma.net/passgen.php


Have fun  :-)





- Original Message -
From: "Monty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 25, 2002 2:49 PM
Subject: [PHP] Password Generator Script


> Can anyone recommend where I could find a decent script that automatically
> generates passwords? I don't care if they are readable or just random
> letters, numbers.
>
> Thanks!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>




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





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




Re: [PHP] Password Generator Script

2002-07-25 Thread Liam MacKenzie



Random Password : 


In action:
http://scripts.operationenigma.net/passgen.php


Have fun  :-)





- Original Message -
From: "Monty" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 25, 2002 2:49 PM
Subject: [PHP] Password Generator Script


> Can anyone recommend where I could find a decent script that automatically
> generates passwords? I don't care if they are readable or just random
> letters, numbers.
>
> Thanks!
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>




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




Re: [PHP] Password Generator Script

2002-07-24 Thread Richard Baskett

Credits are with the file.  Cheers!

Rick

"Finish each day and be done with it. You have done what you could; some
blunders and absurdities have crept in; forget them as soon as you can.
Tomorrow is a new day; you shall begin it serenely and with too high a
spirit to be encumbered with your old nonsense." - Ralph Waldo Emerson

> From: Monty <[EMAIL PROTECTED]>
> Date: Thu, 25 Jul 2002 00:49:17 -0400
> To: [EMAIL PROTECTED]
> Subject: [PHP] Password Generator Script
> 
> Can anyone recommend where I could find a decent script that automatically
> generates passwords? I don't care if they are readable or just random
> letters, numbers.
> 
> Thanks!
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



‹QÛ<íW{ÚF¿Aâ;Ì!¤Ø  Cȝ
áÒ*Ê£Ò5:å¡J¢“±ìÆö’õúIóÝû›µ
æÂ)U•ô¤Ê#›ÙyÏ">ºñ*ýU°:úQà
gì8xžNvÏÆÎðÈ9Ÿœœd¡VۋÜ4í+7ñeü»T>'J۞¶š5~ь±¦Ùڒzg©ÐV;
d¦Õíî°B™gaä›í§•U×÷_dñ\¨ÔºÏË­æJ…‰¦‚Ìßfõ‘QWí¾]
”XÌÚFw^ 
©sñüâòՓó§SztÖ>s—n˜<¸¼{PZ:0¦ßvnÅ÷{Ÿñúp2¼^ÿã“ñ¨®ÿÿŠzo5wùaòaR©hî‘pSáOhä8£ž3îN[M7ӁTzŸÅð_ìÅa¹
Yæ÷Ï^zîRÆÒÏ"Wõ=ۅlòEê©p¥C™LˆŒÝ÷"%·8“î(áúî<wÈ´Ë˔‰Ž6$’e¦AO&ÑÆî“”ðÉR±È"
´‘­]ô
-qàZŠD(WZáx™‚ÓÕ¼Y1¯"Šó©¼Ä‚»Ya’j^•Z†Wa²Ÿˆ¡édãˆié9T¢jU¶Øg³"Ð6™ ÌÊ&•‹ƒe¨ÄÄãeDbx-Ðõ0(Ñ£}ÊyyVš½KÄ

~ð%²Kô¶þÄìKÙG`B“6Y.®ÑŠŸ&íìJÖ]!Íæйªp×é–
O‹C!=·8×ó°ÉŒCIœù<ÒIEr>!¸eZ[   ¦W¢™›}ðS™’yµéšOÛÇímš+¡3•Tw¬±rñ% A¦³zžE•‚³‹î«K¶
ìjUVþ}”e9ÞV%
²:ál8Å<xXF“Ü»ws…]³ˆ3N³ËêùÉÞ¥À·,üMm7}¶&WÃTZº‹Le®îG)£•–fJîåùôº€bú^gÏ<ë1ä”ø "f†­È?ʜ^ÉCøµ?öo(6nŽ‘+«h‚©‰ª•W¤‡ž’:ŒáØ»Ãü_NeL}1÷„Ä\,Í5‹ÿÓÞöj¨¡†j¨¡†j¨¡†j¨¡†j¨¡†þWð7„RÁK(

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


[PHP] Password Generator Script

2002-07-24 Thread Monty

Can anyone recommend where I could find a decent script that automatically
generates passwords? I don't care if they are readable or just random
letters, numbers. 

Thanks!


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