Idea for an RFC for a more powerful (and backward compatible) API of
random number generator functions.

The following psaudocode is self explained (hopfully)

const RAND_ALGO_LIBC
const RAND_ALGO_MERSENNE_TWISTER
const RAND_ALGO_OPENSSL
const RAND_ALGO_GMP
...

// changed functions (added optional $algo argument)
void srand($seed = null, $algo = rand_algo_default())
int rand($min = 0, $max = getrandmax(), $algo = rand_algo_default())
mixed array_rand(array $input, $num_req = 1, $algo = rand_algo_default())
bool shuffle(array &$array, $algo = rand_algo_default())
string str_shuffle(string $str, $algo = rand_algo_default())

// new functions

// set/get the default algo
int rand_algo_default($algo = null)

// get a list of available algos
array rand_algo_list()

// generate random $length bytes
string str_rand($length = 1, $algo = rand_algo_default())

// deprecate functions
mt_srand()
mt_rand()
mt_getrandmax()
openssl_random_pseudo_bytes()
gmp_random()


What do you think?

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to