[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



#!/usr/bin/perl
my $bits = 1024;
$ITER = ($bits / 8); # number of bytes
my $string = "";
for(my $i = 0; $i != $ITER; $i++) {
        $s = sprintf "%0X", int(rand(256));
        $string = $string.$s;
}


printf $string;

On Fri, 2004-04-16 at 08:48, Christopher Fowler wrote:
> This will gen the number.
> 
> #!/usr/bin/perl
> 
> $ITER = 20;
> my $string = "";
> for(my $i = 0; $i != $ITER; $i++) {
>         $string = $string."".int(rand(9));
> }
> 
> print $string;
> 
> 
> On Fri, 2004-04-16 at 08:34, Christopher Fowler wrote:
> > I want to create session ids to be stored as cookies for use in my PERL
> > CGI programs.  The IDs will be store in SQLlite with a key into a table
> > that lists all the name value pairs for that session.  What I want to do
> > is randomly generate a 64bit number and then convert it into a hex
> > string.  This string will be 128 characters long.  I will then set that
> > string as the session id in the cookie and insert it into the table.
> > 
> > What is the best way to generate the number and convert to hex?
> > 
> > Thanks,
> > Chris
> > 
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
&gt; &gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt; 
&gt; _______________________________________________
&gt; Ale mailing list
&gt; Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00567" href="msg00567.html">[ale] Perl random</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00568" href="msg00568.html">[ale] Perl random</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00568.html">[ale] Perl random</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00570.html">[ale] Woof</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00568.html">[ale] Perl random</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00572.html">[ale] Perl random</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00569"><strong>Date</strong></a></li>
<li><a href="threads.html#00569"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>