PHPackages                             g105b/drng - 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. g105b/drng

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

g105b/drng
==========

Deterministic random number generator.

v1(6y ago)258[1 PRs](https://github.com/g105b/drng/pulls)PHPPHP &gt;=7.4

Since Jan 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/g105b/drng)[ Packagist](https://packagist.org/packages/g105b/drng)[ RSS](/packages/g105b-drng/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

Deterministic random number generator
=====================================

[](#deterministic-random-number-generator)

This library generates byte sequences with the ability to convert to integers and floating points. The sequences generated appear to be random, but can be fully determined by providing a known seed value. The main use of this library is in procedural generation algorithms.

The cryptographic algorithms provided by OpenSSL are used to generate the random data, specifically using the Advanced Encryption Standard (AES) operating in Galois/Counter mode (GCM).

Each instance of the `Random` class maintains its AES counter, so there is theoretically no limit to the amount of random data produced. The deterministic nature of this library is possible due to the counter's persistence while generating the initialisation vector, along with the encryption key being set from a provided seed value.

---

Installation
------------

[](#installation)

Composer can be used to install this library into your project. `composer require g105b/drng` will install the latest version. Alternatively, you can modify your project's `composer.json` manually:

```
{
        "require": {
                "g105b/drng": "1.*"
        }
}
```

Usage example
-------------

[](#usage-example)

### Using a string seed to determine the random sequence

[](#using-a-string-seed-to-determine-the-random-sequence)

`string-seed.php`:

```
use g105b\drng\Random;
use g105b\drng\StringSeed;

$rand = new Random(
        new StringSeed("i like cats")
);

echo "Random sequence: ";

for($i = 0; $i < 10; $i++) {
        if($i > 0) {
                echo ", ";
        }

        echo $rand->getInt(1, 10);
}
```

The above example will always output the same sequence, due to the use of the seed "i like cats":

```
Random sequence: 1, 9, 7, 6, 5, 6, 8, 10, 2, 5

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

3

Last Release

2284d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e42344b91ce4b91ab57875969f67a0a6a48de570a08bc65d673b06b72fd3a3f?d=identicon)[g105b](/maintainers/g105b)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/g105b-drng/health.svg)

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

###  Alternatives

[devrabiul/laravel-pwa-kit

Laravel PWA Kit is a lightweight and flexible package to add Progressive Web App (PWA) support to your Laravel applications with ease.

571.4k](/packages/devrabiul-laravel-pwa-kit)[myxtype/eos-client

php eos client offline sign eosphp-ecc

462.1k](/packages/myxtype-eos-client)

PHPackages © 2026

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