PHPackages                             clickalicious/rng - 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. clickalicious/rng

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

clickalicious/rng
=================

The secure Pseudo Random Number Generator (PRNG) for PHP.

v3.0.0(9y ago)22.9k4[1 PRs](https://github.com/clickalicious/rng/pulls)2MITPHPPHP &gt;=5.6.0

Since Mar 23Pushed 8y ago3 watchersCompare

[ Source](https://github.com/clickalicious/rng)[ Packagist](https://packagist.org/packages/clickalicious/rng)[ Docs](https://github.com/clickalicious/rng)[ RSS](/packages/clickalicious-rng/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (5)Versions (8)Used By (2)

[![](https://avatars0.githubusercontent.com/u/26927954?v=3&s=80)](https://avatars0.githubusercontent.com/u/26927954?v=3&s=80)

---

[![Logo of rng](docs/logo-large.png)](docs/logo-large.png)

The secure **Pseudo Random Number Generator** `PRNG` for PHP.

[![Build Status](https://camo.githubusercontent.com/dc095cc06d4d9a382305501f31456f882ddc4da5b4e13ceec9cf1aa8be9a8b18/68747470733a2f2f7472617669732d63692e6f72672f636c69636b616c6963696f75732f726e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clickalicious/rng)[![Codacy branch grade](https://camo.githubusercontent.com/091de68edc5a7804a4feb53717243543e6f4a1595c639fb530c5a067ecaa39d5/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f66353365343638326536353234643434616564623435346164636536386131382f6d61737465722e737667)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade)[![Codacy coverage](https://camo.githubusercontent.com/d63291c093ce985e0e9bd1106a1110473cd9a564fc001c0245fcd66098128488/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f636f7665726167652f66353365343638326536353234643434616564623435346164636536386131382e737667)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade)[![clickalicious open source](https://camo.githubusercontent.com/c244587ebb73cb5386d137729f3bb3348c448eef1782b945b6d03f4f5b5361c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636c69636b616c6963696f75732d6f70656e2d2d736f757263652d677265656e2e7376673f7374796c653d666c6174)](https://clickalicious.de/)[![GitHub release](https://camo.githubusercontent.com/e9987706532f6cef70a77408f4e0dd025984a7ce50d8413198b7e436cbffdb3e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636c69636b616c6963696f75732f726e672e7376673f7374796c653d666c6174)](https://github.com/clickalicious/rng/releases)[![license](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://opensource.org/licenses/MIT)[![Issue Stats](https://camo.githubusercontent.com/4028a67ea7c91e79130c5c2961557c70b66a3a4fc8c249b5b6e29ea107fd4e88/68747470733a2f2f696d672e736869656c64732e696f2f697373756573746174732f692f6769746875622f636c69636b616c6963696f75732f726e672e737667)](https://github.com/clickalicious/rng/issues)[![Dependency Status](https://camo.githubusercontent.com/92259f48059853d82c7b678f612bb68f6939bccd3123913b9dccb2b3d338d366/68747470733a2f2f646570656e64656e637963692e636f6d2f6769746875622f636c69636b616c6963696f75732f726e672f6261646765)](https://dependencyci.com/github/clickalicious/rng)Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Examples](#examples)
- [Requirements](#requirements)
- [Philosophy](#philosophy)
- [Versioning](#versioning)
- [Roadmap](#roadmap)
- [Security-Issues](#security-issues)
- [License »](LICENSE)

Features
--------

[](#features)

- Provides a secure `PRNG`: pseudo random number generator (64-Bit support)
- OOP facade to PHP core functionality
- High performance (developed using a profiler)
- Lightweight and high-quality codebase (following PSR standards e.g. `PSR-1,2,4`)
- Stable, clean + well documented code
- Unit-tested with a good coverage

Examples
--------

[](#examples)

Generate `random number` between 1 and 10 using `OPEN_SSL` random bytes (library default):

```
$generator = new \Clickalicious\Rng\Generator();
$number    = $generator->generate(1, 10);
echo $number;
```

Generate `random number` between 1 and 10 using `PHP_MERSENNE_TWISTER` random bytes:

```
$generator = new \Clickalicious\Rng\Generator(\Clickalicious\Rng\Generator::MODE_PHP_MERSENNE_TWISTER);
$number    = $generator->generate(1, 10);
echo $number;
```

Generate `16 random bytes` using `MODE_OPEN_SSL` random bytes (library default):

```
$generator = new \Clickalicious\Rng\Generator();
$bytes     = $generator->getRandomBytes(16);
```

Generate `32 random bytes` using `NATIVE-PHP` random bytes:

```
$generator = new \Clickalicious\Rng\Generator();
$bytes     = $generator->getRandomBytes(32);
```

### Visualization

[](#visualization)

You can create a visualization of randomization (as you can see below but larger size) through [`visual.php` »](visual.php) (the file is located in root). As you may see: The first square (light grey) is the default PHP random generated noise which is aligned by a pattern (you will see in the large version of the picture). The following three squares a generated using a more secure generator like Open-SSL for example.

[![Logo of rng](docs/visualization.png)](docs/visualization.png)

Requirements
------------

[](#requirements)

- `PHP >= 5.6` (compatible up to version `7.2` as well as `HHVM`)

Philosophy
----------

[](#philosophy)

This library provides a state of the art `PRNG` (**P**seudo **R**andom **N**umber **G**enerator) implementation to generate secure `Pseudo Random Numbers` with PHP. The generation is either based on `Open SSL` or `MCrypt` or as fallback on PHP's internal functionality. The library also provides a very good `Seed generator` on puplic API. If you are interested in the difference between real and pseduo randomness then you could start at [https://www.random.org/randomness/](https://www.random.org/randomness/ "https://www.random.org/randomness/").

[![Scott Adams](https://camo.githubusercontent.com/efdc9aea12a84049158e6a4260431c648035d1a94562960e350a3a4e50b45618/68747470733a2f2f7777772e72616e646f6d2e6f72672f616e616c797369732f64696c626572742e6a7067)](http://dilbert.com/strip/2001-10-25 "Copyright Universal Uclick / Scott Adams")

`DILBERT © 2001 Scott Adams.`

Versioning
----------

[](#versioning)

For a consistent versioning i decided to make use of `Semantic Versioning 2.0.0` . Its easy to understand, very common and known from many other software projects.

Roadmap
-------

[](#roadmap)

- No open issues.

[![Throughput Graph](https://camo.githubusercontent.com/44cc20216a98244853ae26cadbfb04b349e0833cfc5a58077597e3bc00601925/68747470733a2f2f6772617068732e776166666c652e696f2f636c69636b616c6963696f75732f726e672f7468726f7567687075742e737667)](https://waffle.io/clickalicious/rng/metrics)

Security Issues
---------------

[](#security-issues)

If you encounter a (potential) security issue don't hesitate to get in contact with us `opensource@clickalicious.de` before releasing it to the public. So i get a chance to prepare and release an update before the issue is getting shared. Thank you!

Participate &amp; Share
-----------------------

[](#participate--share)

... yeah. If you're a code monkey too - maybe we can build a force ;) If you would like to participate in either **Code**, **Comments**, **Documentation**, **Wiki**, **Bug-Reports**, **Unit-Tests**, **Bug-Fixes**, **Feedback** and/or **Critic** then please let me know as well! [![](https://camo.githubusercontent.com/2ae8719c2efbe82ef2938210c2dc507fffdfa7a73a1d982a01e5b27f7269af52/687474703a2f2f6a70696c6c6f72612e636f6d2f6769746875622d747769747465722d627574746f6e2f696d672f74776565742e706e67)](https://twitter.com/intent/tweet?hashtags=&original_referer=http%3A%2F%2Fgithub.com%2F&text=rng%20-%20Random%20number%20generator%20for%20PHP%20%40phpfluesterer%20%23rng%20%23php%20https%3A%2F%2Fgithub.com%2Fclickalicious%2Frng&tw_p=tweetbutton)

Sponsors
--------

[](#sponsors)

Thanks to our sponsors and supporters:

JetBrainsNavicat[![](https://camo.githubusercontent.com/b0914f08f6b588c7178490d5faf4b159b5c9dd3378288c92812c76aff1936790/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f6173736574732f6d656469612f6f70656e2d67726170682f6a6574627261696e735f323530783235302e706e67)](https://www.jetbrains.com/phpstorm/ "PHP IDE :: JetBrains PhpStorm")[![](https://camo.githubusercontent.com/05c63082503800035599f1c0cfc7bf20806173061e03634107592d18d096e648/687474703a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f656e2f392f39302f5072656d69756d536f66745f4e6176696361745f5072656d69756d5f4c6f676f2e706e67)](http://www.navicat.com/ "Navicat GUI - DB GUI-Admin-Tool for MySQL, MariaDB, SQL Server, SQLite, Oracle & PostgreSQL")###### Copyright

[](#copyright)

Icons made by [Freepik](http://www.freepik.com "Freepik") from [www.flaticon.com](http://www.flaticon.com "Flaticon") is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/ "Creative Commons BY 3.0")

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~153 days

Recently: every ~98 days

Total

6

Last Release

3351d ago

Major Versions

v0.1.0 → v1.0.02016-04-03

v1.1.0 → v2.0.02017-03-10

v2.0.1 → v3.0.02017-04-30

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.0

v1.0.0PHP &gt;=5.4.0

v3.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/41051d0345550be4293d3cdb46cf4eadce771501ed813d3f736e648027f76c0e?d=identicon)[clickalicious](/maintainers/clickalicious)

---

Top Contributors

[![benjamin-carl](https://avatars.githubusercontent.com/u/514566?v=4)](https://github.com/benjamin-carl "benjamin-carl (2 commits)")[![joshk](https://avatars.githubusercontent.com/u/8701?v=4)](https://github.com/joshk "joshk (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

phpprngrandom-bytesrandom-number-generatorrandom-number-generatorsrngrandomgeneratoropensslPRNGRNGnumbermersenneRandomizemtcrypt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clickalicious-rng/health.svg)

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

###  Alternatives

[mistic100/randomcolor

Generate attractive random colors

2451.5M6](/packages/mistic100-randomcolor)[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

375369.6k](/packages/ihor-nspl)[ruafozy/mersenne-twister

Pure-PHP Mersenne Twister

221.5M13](/packages/ruafozy-mersenne-twister)[oat-sa/tao-core

TAO core extension

66143.7k122](/packages/oat-sa-tao-core)[pragmarx/random

Create random chars, numbers, strings

744.6M5](/packages/pragmarx-random)[nubs/random-name-generator

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

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

PHPackages © 2026

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