PHPackages                             kijin/phprandom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kijin/phprandom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kijin/phprandom
===============

Just another random number/string generator for PHP 5

1.2.0(11y ago)61.2k↓100%1MITPHPPHP &gt;=5.0.0

Since Aug 21Pushed 11y ago1 watchersCompare

[ Source](https://github.com/kijin/phprandom)[ Packagist](https://packagist.org/packages/kijin/phprandom)[ Docs](https://github.com/kijin/phprandom)[ RSS](/packages/kijin-phprandom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (0)

PHPRandom
=========

[](#phprandom)

***Just another random number/string generator for PHP 5***

This library is similar to [ircmaxell/RandomLib](https://github.com/ircmaxell/RandomLib), except it is compatible with PHP 5.0 and above, and comes with a much simpler interface. Seriously, PHP ain't Java. Why do we need a dozen files and classes inheriting one another just to get some random bytes? :p

How to Install
--------------

[](#how-to-install)

Traditional method:

```
include 'phprandom.php';

```

Composer:

```
"require": {
    "kijin/phprandom": "dev-master"
}

```

How to Use
----------

[](#how-to-use)

Get a random integer between two endpoints (inclusive):

```
$random = PHPRandom::getInteger($min, $max);

```

Get a random floating-point number between 0 and 1:

```
$random = PHPRandom::getFloat();

```

Get a random alphanumeric string (0-9, a-z, A-Z):

```
$random = PHPRandom::getString($length);

```

Get a random hexademical string (0-9, a-f):

```
$random = PHPRandom::getHexString($length);

```

Get a random binary string:

```
$random = PHPRandom::getBinary($length);

```

Find out where your precious entropy comes from:

```
$sources = PHPRandom::listSources();

```

Configuration
-------------

[](#configuration)

PHPRandom requires no configuration.

You don't have to choose whether you want low-quality or high-quality entropy. You always get the highest quality of entropy that your system supports. Since the marginal cost of asking for high-quality entropy is negligible in most cases, there is rarely any need to ask for low-quality entropy.

Weaker sources of entropy are automatically mixed with other sources using the best mixing algorithm that your system supports.

Supported sources, in order of preference:

- `openssl_random_pseudo_bytes()`
- `mcrypt_create_iv()` with `MCRYPT_DEV_URANDOM`
- `mcrypt_create_iv()` with `MCRYPT_RAND` (Windows only)
- `/dev/urandom` (Linux/Unix only)
- `rand()` xor `mt_rand()`

Supported mixers, in order of preference:

- `hash_hmac()` with SHA-256
- `sha1()`

License
-------

[](#license)

PHPRandom is free software released under the MIT license.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

5

Last Release

4245d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae69f2567c3a5a9c37e2231606175cd09e0980534b285c934328fd007401b40d?d=identicon)[kijin](/maintainers/kijin)

---

Top Contributors

[![kijin](https://avatars.githubusercontent.com/u/164058?v=4)](https://github.com/kijin "kijin (23 commits)")

---

Tags

random

### Embed Badge

![Health badge](/badges/kijin-phprandom/health.svg)

```
[![Health](https://phpackages.com/badges/kijin-phprandom/health.svg)](https://phpackages.com/packages/kijin-phprandom)
```

###  Alternatives

[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k655.0M404](/packages/paragonie-random-compat)[ircmaxell/random-lib

A Library For Generating Secure Random Numbers

84130.2M119](/packages/ircmaxell-random-lib)[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[pragmarx/random

Create random chars, numbers, strings

714.2M5](/packages/pragmarx-random)[paragonie/random-lib

A Library For Generating Secure Random Numbers

703.3M26](/packages/paragonie-random-lib)[nubs/random-name-generator

A library to create interesting, sometimes entertaining, random names.

135680.2k3](/packages/nubs-random-name-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
