I have looked at your bcrand() function and noticed that it does not work.
You have called openssl_random_pseudo_bytes() as if the arguments were "min, max", but actually they are "length, &output", at least for the current version of PHP.
I have replaced it with mt_rand() and now the function works as expected:
return bcadd(bcmul(bcdiv(mt_rand(), mt_getrandmax(), strlen($max)), bcsub(bcadd($max, 1), $min)), $min);
I have looked at your bcrand() function and noticed that it does not work.
You have called openssl_random_pseudo_bytes() as if the arguments were "min, max", but actually they are "length, &output", at least for the current version of PHP.
I have replaced it with mt_rand() and now the function works as expected:
return bcadd(bcmul(bcdiv(mt_rand(), mt_getrandmax(), strlen($max)), bcsub(bcadd($max, 1), $min)), $min);