Re: RFC: a package to interface to Random number web services
| From: | Xavier Noguer | Date: | Thu, 02 Jan 2003 13:32:16 +0000 |
| Subject: | Re: RFC: a package to interface to Random number web services | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-12019@lists.php.net to get a copy of this message | ||
+1 for the package. What about Math_RandomGenService?
El Mié 01 Ene 2003 19:17, Jesus M. Castagnetto escribió:
> There are several web-based services that provide some math info/data. The
> two I have played with are www.random.org and HotBits
> (http://www.fourmilab.ch/hotbits/). Both sites provide true random numbers,
> which can be useful for a variety of purposes. The HoBits site uses
> radioactive decay for generating their numbers, and random.org tests theirs
> with a battery of statisical analysis to assure true randomness.
>
> Initially I made an interface only for random.org, but then I found
> HotBits, and modify the whole system to use that too. It uses static
> methods to call or create the appropriate objects. HotBits returns a string
> of hexadecimals representing bytes, and random.org can return decimal
> numbers or a list of bytes (in hexadecimal).
>
> For lack of a better name I am calling it Math_WebService, but that name
> can be changed. Get the code using:
>
> $ pear install
> http://www.scripps.edu/~jesusmc/stuff/Math_WebService-0.8.tgz
>
> In both services, I named the services' methods as the CGIs being used at
> the their respective sites (mapped internally to the appropriate method).
> An example of usage is below:
>
> include_once 'Math/WebService.php';
>
> echo "random.org\n";
> $ran =& Math_WebService::create('randomorg');
> echo "* randbyte(nbytes=8)\n";
> $res = $ran->request('randbyte', array('nbytes'=>8));
> print_r($res);
> echo "* randnum(num=10)\n";
> $res = $ran->request('randnum', array('num'=>10));
> print_r($res);
> echo "* again randnum() using prev parameters\n";
> $res = $ran->more();
> print_r($res);
>
> echo "\nhotbits\n";
> $hot =& Math_WebService::create('hotbits');
> $res = $hot->request('hotbits',array('nbytes'=>5));
> echo "* hotbits(nbytes=5)\n";
> print_r($res);
> $res = $hot->more();
> echo "* again hotbits() using prev parameters\n";
> print_r($res);
>
> echo "\nrandom.org\n";
> $res = Math_WebService::request('randomorg', 'randnum',
> array('num'=>7));
> echo "* randnum(num=7) using a factory method from Math_WebService\n";
> print_r($res);
>
> Opinions/suggestions for code and name/+1s are welcomed.
>
> Cheers.
>
> =====
> --- Jesus M. Castagnetto (jcastagnetto@yahoo.com)
>
> Research:
> http://metallo.scripps.edu/
> Personal: http://www.castagnetto.org/
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com