Skip to content

bcrand() not working #16

@danielmarschall

Description

@danielmarschall

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions