Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 24, 2024 via composer

paragonie/random_compat v2.0.21

PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
Package summary
Share
0
issues
1
license
1
MIT
Package created
7 Jul 2015
Version published
16 Feb 2022
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
paragonie/random_compat@v2.0.21
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of paragonie/random_compat 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does paragonie/random_compat do?

The paragonie/random_compat is a PHP 5.x polyfill for random_bytes() and random_int() from PHP 7. It aims to provide these functions from PHP 7 for use in a PHP 5 environment. Built and maintained by Paragon Initiative Enterprises, this library is intended to be used in PHP versions that are supported as per the official PHP documentation.

The library is robust, but it should be subject to rigorous security testing before it is deployed in a production environment.

How do you use paragonie/random_compat?

To use the paragonie/random_compat library in your project, you will need to install it either manually, through a PHP Archive, or with Composer.

By using Composer, the library can be added to your project with the following commands, depending on your specific needs:

# For libraries and frameworks that support PHP 5 but may be used by
# other software that only supports PHP 7:
composer require paragonie/random_compat:>=2

# For software that explicitly needs PHP 5 support:
composer require paragonie/random_compat:<9.99

To use the library, include it in your PHP script and then you can call the random_bytes() and random_int() functions. Here is an example of how you can use these functions:

# To generate a string of random bytes:
try {
    $string = random_bytes(32);
} catch (Exception $e) {
    // handle exception
}
# To generate a random integer between two given integers (inclusive):
try {
    $int = random_int(0, 255);
} catch (Exception $e) {
    // handle exception
}

Remember to handle exceptions appropriately as outlined in the provided usage examples.

Where are the paragonie/random_compat docs?

Documentation for paragonie/random_compat can be found in the README file of the GitHub repository located at https://github.com/paragonie/random_compat.git. The README provides comprehensive details about the usage, the purpose, installation process, and troubleshooting tips relating to the library, making it the primary source of documentation for this PHP package.