Page MenuHomeDevCentral

Use cryptographically secure pseudo-random integers
ClosedPublic

Authored by dereckson on Apr 9 2022, 12:04.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 22:06
Unknown Object (File)
Thu, Apr 18, 13:25
Unknown Object (File)
Thu, Apr 18, 02:15
Unknown Object (File)
Wed, Apr 17, 15:07
Unknown Object (File)
Tue, Apr 16, 00:05
Unknown Object (File)
Sun, Apr 14, 13:30
Unknown Object (File)
Sun, Apr 14, 09:39
Unknown Object (File)
Wed, Apr 10, 15:29
Subscribers
None

Details

Summary

Methods from Identifiers\Random were currently implemented using
the Mersenne Twister general-purpose pseudorandom number generator.

As randomness is often used as a source to generate credentials,
and to also offer unbiaised results for games, this changes switch
to the CSPRNG method random_int. The random_bytes method was already used.

According PHP manual, the "cryptographically secure pseudo-random number
generator (CSPRNG) API provides an easy and reliable way to generate
crypto-strong random integers and bytes for use within cryptographic contexts."

As our library is PHP 7+ (actually PHP 8.1+), the CSPRNG methods are always
available.

Test Plan

Run unit tests, no regression detected.

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable