paragonie/random_compat
PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
v9.99.100
708M downloads/mo
#114 most downloaded on composer
paragonie/random_compat
What this package is like to depend on
Last release 5 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 1.8 years
Most releases are documented
notes for 52 of 59 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
59 releases · first in 2015
0 releases in the last 12 months
see the full history below
Release timeline
59 releases · Jul 2015 to Feb 2022Releases
latest 59-
v9.99.10015 Oct 2020 -
v9.99.9902 Jul 2018Nothing published for this version
-
v2.0.2116 Feb 2022 -
v2.0.2017 Apr 2021Release notes
Open source →- Switched from Travis CI to Github Actions
- Minor whitespace change (never-ending Scrutinizer suggestion)
-
v2.0.1915 Oct 2020Release notes
Open source →- Adds support for PHP 8 projects in Composer constraint
- Fixes Travis CI for future development (Note: This required largely disabling Psalm.)
-
v2.0.1803 Jan 2019Release notes
Open source →- If
/dev/urandomcannot be read on Unix-based operating systems,
a Exception with a specific error message will be thrown. - Fixed Psalm nits.
- Updated the README to include a reference to the support contract
offering by Paragon Initiative Enterprises.
Release notes
Open source →- If
/dev/urandomcannot be read on Unix-based operating systems, a Exception with a specific error message will be thrown. - Fixed Psalm nits.
- Updated the README to include a reference to the support contract offering by Paragon Initiative Enterprises.
- If
-
v2.0.1704 Jul 2018Release notes
Open source →- Version 2.0.16 failed Psalm checks on PHP v5.6 with Psalm v1. We could not reproduce this failure locally, so we've suppressed the
MissingReturnTypecheck (that is to say, demoted it to "info").
Release notes
Open source →- Version 2.0.16 failed Psalm checks on PHP v5.6 with Psalm v1.
We could not reproduce this failure locally, so we've suppressed the
MissingReturnTypecheck (that is to say, demoted it to "info").
- Version 2.0.16 failed Psalm checks on PHP v5.6 with Psalm v1. We could not reproduce this failure locally, so we've suppressed the
-
v2.0.1604 Jul 2018Release notes
Open source →- Fixed type-checking consistencies that forced us to use Psalm in non-strict mode (i.e.
totallyTyped="false"). - README cleanup, added a header to the Version 9.99.99 section.
- If you're confused by
v9.99.99and it's causing stuff to break, see this section of the README for the solution to your problem.
- If you're confused by
- Trimmed down and annotated our
psalm.xmlfile with explanations for why each assertion is suppressed.
Release notes
Open source →- Fixed type-checking consistencies that forced us to use Psalm in
non-strict mode (i.e.
totallyTyped="false"). - README cleanup, added a header to the Version 9.99.99 section.
- If you're confused by
v9.99.99and it's causing stuff to break, see this section of the README for the solution to your problem.
- If you're confused by
- Trimmed down and annotated our
psalm.xmlfile with explanations for why each assertion is suppressed.
- Fixed type-checking consistencies that forced us to use Psalm in non-strict mode (i.e.
-
v2.0.1508 Jun 2018Release notes
Open source →- A reported, but difficult to reproduce, problem with file inclusion on some Windows machines was fixed by replacing
/withDIRECTORY_SEPARATOR.
For most users (i.e. not running Windows) this change should be of zero consequence. For everyone else, it should mean random_compat magically works when it didn't before.
Release notes
Open source →- A reported, but difficult to reproduce, problem with file inclusion on
some Windows machines
was fixed by replacing
/withDIRECTORY_SEPARATOR. For most users (i.e. not running Windows) this change should be of zero consequence. For everyone else, it should mean random_compat magically works when it didn't before.
- A reported, but difficult to reproduce, problem with file inclusion on some Windows machines was fixed by replacing
-
v2.0.1406 Jun 2018Release notes
Open source →- Update version information.
- Updated README with better instructions, including new information about the
v9.99.99tag.
Release notes
Open source →- Update version information.
- Updated README with better instructions, including new information
about the
v9.99.99tag.
-
v2.0.1306 Jun 2018Release notes
Open source →- #139 - Add
polyfillkeyword to composer.json - Ensure the docblocks are consistent to aid static analysis efforts in other libraries; see https://github.com/paragonie/random_compat/commit/cbe0b11b78140bc62a921fec33a730fdaa6540d6
- #139 - Add
-
v2.0.1204 Apr 2018 -
v2.0.1127 Sep 2017Release notes
Open source →- Minor docblock corrections.
- Re-issuing a PHP Archive to attempt to address an issue with the Phar provided. See #134.
-
v2.0.1013 Mar 2017Release notes
Open source →- Mcrypt can now be used on PHP < 5.3.7 if you're not on Windows.
- Minor boyscouting changes.
-
v2.0.903 Mar 2017 -
v2.0.803 Mar 2017Release notes
Open source →- Prevent function already declared error for
random_int()caused by misusing the library (really you should only ever includelib/random.phpand never any of the other files). See #125.
- Prevent function already declared error for
-
v2.0.727 Feb 2017Nothing published for this version
-
v2.0.627 Feb 2017 -
v2.0.527 Feb 2017 -
v2.0.407 Nov 2016Release notes
Open source →- Don't unnecessarily prevent
mcrypt_create_iv()from being used. See #111.
- Don't unnecessarily prevent
-
v2.0.317 Oct 2016Release notes
Open source →- Updated
lib/error_polyfill.phpto resolve corner cases. - The README was updated to help users troubleshoot and fix insecure environments.
- Tags will now be signed by the GnuPG key used by the security team at Paragon Initiative Enterprises, LLC.
- Updated
-
v2.0.203 Apr 2016Release notes
Open source →Added a consistency check (discovered by Taylor Hornby in his PHP encryption library). It wasn't likely causing any trouble for us.
-
v2.0.118 Mar 2016 -
v2.0.018 Mar 2016Release notes
Open source →Due to downstream errors, the OpenSSL removal now belongs in version 2.0.0.
-
v1.4.304 Apr 2018Nothing published for this version
-
v1.4.213 Mar 2017Nothing published for this version
-
v1.4.118 Mar 2016Nothing published for this version
-
v1.4.018 Mar 2016Nothing published for this version
-
v1.3.118 Mar 2016 -
v1.3.017 Mar 2016Release notes
Open source →-
Removed
openssl_random_pseudo_bytes()entirely. If you are using random_compat in PHP on a Unix-like OS but cannot access/dev/urandom, version 1.3+ will throw anException. If you want to trust OpenSSL, feel free to write your own fallback code. e.g.try { $bytes = random_bytes(32); } catch (Exception $ex) { $strong = false; $bytes = openssl_random_pseudo_bytes(32, $strong); if (!$strong) { throw $ex; } }
-
-
v1.2.318 Mar 2016Nothing published for this version
-
v1.2.211 Mar 2016Release notes
Open source →- To prevent applications from hanging, if
/dev/urandomis not accessible to PHP, skip mcrypt (which just fails before giving OpenSSL a chance and was morally equivalent to not offering OpenSSL at all).
- To prevent applications from hanging, if
-
v1.2.129 Feb 2016Release notes
Open source →- PHP 5.6.10 - 5.6.12 will hang when mcrypt is used on Unix-based operating
systems (PHP bug 69833). If you are
running one of these versions, please upgrade (or make sure
/dev/urandomis readable) otherwise you're relying on OpenSSL.
- PHP 5.6.10 - 5.6.12 will hang when mcrypt is used on Unix-based operating
systems (PHP bug 69833). If you are
running one of these versions, please upgrade (or make sure
-
v1.2.006 Feb 2016Release notes
Open source →-
Whitespace and other cosmetic changes
-
Added a changelog.
-
We now ship with a command line utility to build a PHP Archive from the command line.
Every time we publish a new release, we will also upload a .phar to Github. Our public key is signed by our GPG key.
-
-
1.1.629 Jan 2016Release notes
Open source →- Eliminate
open_basedirwarnings by detecting this configuration setting. (Thanks @oucil for reporting this.) - Added install instructions to the README.
- Documentation cleanup (there is, in fact, no
MCRYPT_CREATE_IVconstant, I meant to writeMCRYPT_DEV_URANDOM)
- Eliminate
-
1.1.506 Jan 2016 -
1.1.410 Dec 2015 -
1.1.309 Dec 2015 -
1.1.209 Dec 2015Release notes
Open source →Don't instantiate COM if it's a disabled class. Removes the E_WARNING on Windows.
-
1.1.101 Dec 2015 -
1.1.010 Nov 2015Release notes
Open source →Fix performance issues with ancient versions of PHP on Windows, but dropped support for PHP < 5.4.1 without mcrypt on Windows 7+ in the process. Since this is a BC break, semver dictates a minor version bump.
-
1.0.1023 Oct 2015Release notes
Open source →- Avoid a performance killer with OpenSSL on Windows PHP 5.3.0 - 5.3.3 that was affecting WordPress users.
- Use
$var = nullinstead ofunset($var)to avoid triggering the garbage collector and slowing things down.
-
1.0.920 Oct 2015Release notes
Open source →There is an outstanding issue
mcrypt_create_iv()and PHP 7'srandom_bytes()on Windows reported by @nicolas-grekas caused byproc_open()and environment variable handling (discovered by Appveyor when developing Symfony).Since the break is consistent, it's not our responsibility to fix it, but we should fail the same way PHP 7 will (i.e. throw an
Exceptionrather than raise an error and then throw anException). -
1.0.818 Oct 2015Release notes
Open source →- Fix usability issues with Windows (
new COM('CAPICOM.Utilities.1')is not always available). - You can now test all the possible drivers by running
phpunit.sh eachin thetestsdirectory.
- Fix usability issues with Windows (
-
1.0.716 Oct 2015 -
1.0.616 Oct 2015Release notes
Open source →Don't let the version number fool you, this was a pretty significant change.
- Added support for ext-libsodium, if it exists on the system. This is morally
equivalent to adding
getrandom(2)support without having to expose the syscall interface in PHP-land. - Relaxed open_basedir restrictions. In previous versions, if open_basedir was
set, PHP wouldn't even try to read from
/dev/urandom. Now it will still do so if you can. - Fixed integer casting inconsistencies between random_compat and PHP 7.
- Handle edge cases where an integer overflow turns one of the parameters into a float.
One change that we discussed was making
random_bytes()andrandom_int()strict typed; meaning you could only pass integers to either function. While most veteran programmers are probably only doing this already (we strongly encourage it), it wouldn't be consistent with how these functions behave in PHP 7. Please use these functions responsibly.We've had even more of the PHP community involved in this release; the contributors list has been updated. If I forgot anybody, I promise you it's not because your contributions (either code or ideas) aren't valued, it's because I'm a bit overloaded with information at the moment. Please let me know immediately and I will correct my oversight.
Thanks everyone for helping make random_compat better.
- Added support for ext-libsodium, if it exists on the system. This is morally
equivalent to adding
-
1.0.508 Oct 2015Release notes
Open source →Got rid of the methods in the
Throwableinterface, which was causing problems on PHP 5.2. While we would normally not care about 5.2 (since 5.4 and earlier are EOL'd), we do want to encourage widespread adoption (e.g. Wordpress). -
1.0.402 Oct 2015Release notes
Open source →Removed redundant
if()checks, sincelib/random.phpis the entrypoint people should use. -
1.0.302 Oct 2015Release notes
Open source →This release contains bug fixes contributed by the community.
- Avoid a PHP Notice when PHP is running without the mbstring extension
- Use a compatible version of PHPUnit for testing on older versions of PHP
Although none of these bugs were outright security-affecting, updating ASAP is still strongly encouraged.
-
1.0.223 Sep 2015Release notes
Open source →Less strict input validation on
random_int()parameters. PHP 7'srandom_int()accepts strings and floats that look like numbers, so we should too.Thanks @dd32 for correcting this oversight.
-
v1.0.110 Sep 2015Release notes
Open source →Instead of throwing an Exception immediately on insecure platforms, only do so when
random_bytes()is invoked.Release notes
Open source →fdc471f
Instead of throwing an Exception immediately on insecure platforms, only do so when random_bytes() is invoked.
-
v1.0.007 Sep 2015Release notes
Open source →Our API is now stable and forward-compatible with the CSPRNG features in PHP 7 (as of 7.0.0 RC3).
A lot of great people have contributed their time and expertise to make this compatibility library possible. That this library has reached a stable release is more a reflection on the community than it is on PIE.
We are confident that random_compat will serve as the simplest and most secure CSPRNG interface available for PHP5 projects.
-
v0.9.701 Sep 2015Release notes
Open source →An attempt to achieve compatibility with Error/TypeError in the RFC.
This should be identical to 1.0.0 sans any last-minute changes or performance enhancements.
-
0.9.531 Jul 2015Release notes
Open source →- Validate that
/dev/urandomis a character device- Reported by @lokdnet
- Investigated by @narfbg and frymaster on StackOverflow
- Remove support for
/dev/arandomwhich is an old OpenBSD feature, thanks @jedisct1 - Prevent race conditions on the
filetype()check, thanks @jedisct1 - Buffer file reads to 8 bytes (performance optimization; PHP defaults to 8192 bytes)
- Validate that
-
0.9.427 Jul 2015Release notes
Open source →- Add logic to verify that
/dev/arandomand/dev/urandomare actually devices. - Some clean-up in the comments
- Add logic to verify that
-
0.9.322 Jul 2015Release notes
Open source →Unless the Exceptions change to PHP 7 fails, this should be the last pre-release version. If need be, we'll make one more pre-release version with compatible behavior.
Changes since 0.9.2:
- Prioritize
/dev/arandomand/dev/urandomover mcrypt. @oittaa removed the -1 and +1 juggling on$rangecalculations forrandom_int() - Whitespace and comment clean-up, plus better variable names
- Actually put a description in the composer.json file...
- Prioritize
-
0.9.217 Jul 2015Release notes
Open source →- Consolidated
$range > PHP_INT_MAXlogic with$range <= PHP_INT_MAX(thanks @oittaa and @CodesInChaos) tests/phpunit.shnow also runs the tests withmbstring.func_overloadandopen_basedir- Style consistency, whitespace cleanup, more meaningful variable names
- Consolidated
-
0.9.110 Jul 2015Release notes
Open source →- Return random values on integer ranges >
PHP_INT_MAX(thanks @CodesInChaos) - Determined CSPRNG preference:
mcrypt_create_iv()withMCRYPT_DEV_URANDOM/dev/arandom/dev/urandomopenssl_random_pseudo_bytes()
- Optimized backend selection (thanks @lt)
- Fix #3 (thanks @scottchiefbaker)
- Return random values on integer ranges >
-
0.9.007 Jul 2015Release notes
Open source →This should be a sane polyfill for PHP 7's
random_bytes()andrandom_int(). We hesitate to call it production ready until it has received sufficient third party review.