# paragonie/random_compat

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

Repository: https://github.com/paragonie/random_compat
Canonical: https://ross.abutalabs.com/products/random_compat
Homepage: https://paragonie.com/projects
Language: PHP
License: MIT
License Family: permissive
Topics: php, php5, secure, secure-by-default, random, random-bytes, csprng, randomness, random-int, polyfill, random-generation, randomization
Last push: 2026-02-23T16:45:02+00:00

## Health v2 (maintenance only)
Score: 54/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 69, release rhythm 8, longevity 100
- inputs: {"age_days": 4075, "days_push": 191, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 8154, forks 153 (observed 2026-08-28T04:10:13.907087+00:00)

## What it is
A PHP 5.x polyfill providing the random_bytes() and random_int() CSPRNG functions that were introduced in PHP 7. It fails with an exception rather than falling back to insecure randomness, making it secure-by-default.

## Use cases
- generate cryptographically secure random bytes in php 5
- polyfill random_int for older php versions
- secure random token generation in legacy php apps
- support php 5 in a library that uses php 7 random functions
- avoid insecure mt_rand for randomness

## When to choose
- you maintain a library or app that must support PHP 5.x and needs CSPRNG randomness
- you want a drop-in polyfill that never falls back to insecure random data

## When to avoid
- you are on PHP 7 or newer, where random_bytes() and random_int() are built in
- you need general-purpose randomness rather than cryptographic randomness

## Facets
- artifact type: library
- maturity: maintenance
- function: cryptography, security, sdk
- domain: security, developer-tools, programming-languages
- platform: php
- tags: polyfill, csprng, random-bytes, random-int, php5, secure-by-default

## Member repositories
- paragonie/random_compat (main) score 54

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:13.907087+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:29:46.093509+00:00, confidence not recorded.
  - readme: https://github.com/paragonie/random_compat (fetched 2026-08-28T04:10:13.907087+00:00, sha b374ce6a5541)
  - homepage: https://paragonie.com/projects (fetched 2026-08-29T08:28:29.233329+00:00, sha cc0dd2480199)
  - site_page: https://paragonie.com/info (fetched 2026-08-29T08:28:29.236911+00:00, sha 2b4c8084191a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
