Re: Random Numbers/Letters

From: Jeff Fitzmyers <flume33(at)yahoo(dot)com>
To: "Hillensbeck, Preston" <PHillensbeck(at)sfbcic(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Random Numbers/Letters
Date: 2002-03-14 18:22:55
Message-ID: 80FEA902-3778-11D6-8101-0003938387F4@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I need to find a way to generate random numbers and
> letters together

I m no crytpo expert, but here is a php function I am toying with. The
reason I add the 200 characters is because I read somewhere that md5
'produces more random results' if it has a chunk to crunch. Maybe it is
inefficient, insecure or doesn't really add anything??

<? // generate a random string
function rand_string() {
list($usec,$sec) = explode(" ", microtime());
mt_srand($sec * $usec);
$rand = mt_rand();
$start = mt_rand(1,198);
$length = mt_rand(1,198);
// change these 400 characters often
$text ='q54SMqa54VBPMqa54L3zxDKGzxs3zxswedWbbikplwlx
GAZX5Fy9hy7uMqn!aWE&ujNmaCVBPMqa54L3swedYeappCVBLd9c
vt9gbF!SazxsFDSagfHvt9gbFDSazMqKIF4cvxeEDh7ewSSKJTYe
dJMa5K54SWkGB3zxXCVazxsw989A5xswDS5FDS8nplavswAZXRC9
84cvfrTYeda5KJHG4Guv3321QN764r6yweswAZXR298lcvfraCxs
FDSaa5KJHG4321QN765Fz9hy7uMqnyaWEmitpl4MqvfhjcvytMzx
sw477as98j587UIJHqfrJHggrCVBLd9cjkGBMzxsw4ua52wm98j5
87UIJHqfrJHkjsNmAZzxDKGzxs7uj7ewr54AZXCVaz';
$text = substr($text, $start, $length);
$rand_s = md5($rand . $text);
return $rand_s;
}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-03-14 18:47:12 Re: UPDATE and SELECT result difference
Previous Message Bruce Momjian 2002-03-14 18:17:07 Re: pgmonitor