paragonie/random_compat

PHP 5.x support for random_bytes() and random_int()

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 25 minutes ago
Added to GitGenius on September 8th, 2026
Created on July 7th, 2015
Open Issues & Pull Requests: 5 (+0)
GitHub issues: Enabled
Number of forks: 153
Total Stargazers: 8,153 (+0)
Total Subscribers: 36 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 12.8 days
Mean response time: 12.8 days
90th percentile: 12.8 days
Tracked items: 1

Most active contributors

Sign in to see contributor activity.

Related repositories by overlapping contributors

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 0
New in 7 days: 0
Closed in 7 days: 0
Avg open age: N/A days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

random_compat is a PHP polyfill that provides cryptographically secure random number generation functions for PHP 5.x projects.

The library solves the problem of generating cryptographically secure random data in older PHP versions that lack the random_bytes() and random_int() functions introduced in PHP 7. It exposes these two CSPRNG functions with identical behavior to their native PHP 7 counterparts, allowing developers to write code that works across both PHP 5 and PHP 7 environments. The polyfill uses the operating system's random data sources where available and will throw an exception rather than fall back to insecure randomness if it cannot safely generate data.

Projects maintaining PHP 5 compatibility while needing secure random generation are the primary use case. This includes libraries and frameworks that must support older PHP versions or applications not yet upgraded to PHP 7. The tool is designed as a drop-in replacement for the native functions, so code written against it will work identically when eventually run on PHP 7 without modification. Installation is available through Composer or as a signed PHP Archive, with manual installation also supported.

Development activity shows a mature, security-conscious approach. The project explicitly recommends using stable releases rather than the master branch and emphasizes that the library has been examined by security experts while acknowledging the possibility of overlooked issues. The tool prioritizes fail-safe behavior by refusing to fall back to insecure randomness under any circumstances, instead throwing an exception to force developers to address the underlying problem. Documentation includes detailed guidance on exception handling differences between PHP 5 and PHP 7, reflecting attention to real-world compatibility concerns.