Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Random Compat Laravel Package

paragonie/random_compat

PHP 5 polyfill for random_bytes() and random_int(), providing secure, cryptographically strong randomness on older PHP versions. Uses the best available system sources and falls back safely, helping apps generate tokens, keys, IDs, and nonces consistently across environments.

View on GitHub
Deep Wiki
Context7
v2.0.21
  • Fix #175 - Fix CAPICOM usage on Windows
  • Widen PHPUnit version range
  • Test PHP 8.1 in GitHub Actions (thanks @jrfnl!)
  • Fix unit tests on PHP 8.1
v2.0.20
  • Switched from Travis CI to Github Actions
  • Minor whitespace change (never-ending Scrutinizer suggestion)
v2.0.19
  • Adds support for PHP 8 projects in Composer constraint
  • Fixes Travis CI for future development (Note: This required largely disabling Psalm.)
v2.0.18
  • If /dev/urandom cannot 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.
v2.0.17
  • 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 MissingReturnType check (that is to say, demoted it to "info").
v2.0.16
  • 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.99 and it's causing stuff to break, see this section of the README for the solution to your problem.
  • Trimmed down and annotated our psalm.xml file with explanations for why each assertion is suppressed.
v2.0.15
  • A reported, but difficult to reproduce, problem with file inclusion on some Windows machines was fixed by replacing / with DIRECTORY_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.
v2.0.14
  • Update version information.
  • Updated README with better instructions, including new information about the v9.99.99 tag.
v2.0.13
v1.4.3
  • Fix version number in constant in lib/random.php
  • Upgrade your dependency from ^1 to ^1|^2 if you want other changes (i.e. better compatibility with type-safety), because the v2 branch is where most of the development effort is focused. Continued support for v1.x is considered "only for emergencies".
v2.0.12
  • Minor docblock issue that's breaking Psalm downstream.
v2.0.11
  • Minor docblock corrections.
  • Re-issuing a PHP Archive to attempt to address an issue with the Phar provided. See #134.
v2.0.10
  • Mcrypt can now be used on PHP < 5.3.7 if you're not on Windows.
  • Minor boyscouting changes.
v1.4.2

Backported changes from version 2:

  • Version 2.0.10 - 2017-03-13
    • Mcrypt can now be used on PHP < 5.3.7 if you're not on Windows.
  • Version 2.0.9 - 2017-03-03
    • More Psalm integration fixes.
  • Version 2.0.8 - 2017-03-03
    • Prevent function already declared error for random_int() caused by misusing the library (really you should only ever include lib/random.php and never any of the other files). See #125.
  • Version 2.0.6, 2.0.7 - 2017-02-27
    • Just updates to psalm.xml to silence false positives.
  • Version 2.0.5 - 2017-02-27
    • Run random_compat through the static analysis tool, psalm, as part of our continuous integration process.
    • Minor readability enhancements (#122 and several docblock changes).
  • Version 2.0.4 - 2016-11-07
    • Don't unnecessarily prevent mcrypt_create_iv() from being used. See #111.
  • Version 2.0.3 - 2016-10-17
  • Version 2.0.2 - 2016-04-03
    • Added a consistency check (discovered by Taylor Hornby in his PHP encryption library). It wasn't likely causing any trouble for us.
v2.0.9

More Psalm integration fixes.

v2.0.8

Prevent function already declared error for random_int() caused by misusing the library (really you should only ever include lib/random.php and never any of the other files). See #125.

v2.0.7

Apparently psalm locally works, but psalm on Travis CI likes to randomly fail to recognize that a constant exists when it does.

Yeah.... no.

I didn't bother updating the changelog. It's a ditto for 2.0.6.

v2.0.6
  • Just an update to psalm.xml to silence false positives.
v2.0.5
  • Run random_compat through the static analysis tool, psalm, as part of our continuous integration process.
  • Minor readability enhancements (#122 and several docblock changes).
v2.0.4
  • Don't unnecessarily prevent mcrypt_create_iv() from being used. See #111.

Please speak up if this change causes issues for you.

v2.0.3
v2.0.2

Added a consistency check (discovered by Taylor Hornby in his PHP encryption library). It wasn't likely causing any trouble for us.

v2.0.1

Update comment in random.php

v1.4.1

Update comment in random.php

v2.0.0

Due to downstream errors, the OpenSSL removal now belongs in version 2.0.0.

v1.4.0

Restored OpenSSL in the version 1 branch in preparation to remove OpenSSL in version 2.

v1.2.3
  • Add more possible values to open_baseir check. Thanks @narfbg
v1.3.1
  • Add more possible values to open_baseir check. Thanks @narfbg
v1.3.0

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 an Exception. 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.2
  • To prevent applications from hanging, if /dev/urandom is not accessible to PHP, skip mcrypt (which just fails before giving OpenSSL a chance and was morally equivalent to not offering OpenSSL at all).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport