PHPackages                             klg/random - 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. klg/random

Abandoned → [paragonie/random\_compat](/?search=paragonie%2Frandom_compat)ArchivedLibrary

klg/random
==========

Cryptographically secure random generator for PHP.

060PHP

Since Jan 10Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mwgamera/php-klg-random)[ Packagist](https://packagist.org/packages/klg/random)[ RSS](/packages/klg-random/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

```
Cryptographically secure random generators for PHP.

As PHP core itself does not provide any kind of secure random generator,
extensions and other not portable means of obtaining entropy must be used.
This package provides a common interface \klg\random\RandomGenerator
for multiple secure random bit generators accessible from PHP.
It exposes the following implementations of it:
\klg\random\OpenSSLGenerator  which uses openssl_random_pseudo_bytes
\klg\random\McryptGenerator   which uses mcrypt_create_iv
\klg\random\EGDGenerator      which reads from Entropy Gathering Daemon
\klg\random\KernelGenerator   which reads from /dev/urandom
\klg\random\PHPNativeGenerator  which is slow but fully portable NRBG

Depending on availability of extensions \klg\random\RandomGeneratorFactory
will instantiate the best available implementation.

Additionally as a convenience wrapper a klg\random\SecureRandom class is
provided with few utility methods that allow generating random numbers and
cryptographic tokens (as for use in password reset procedure, etc) easily.

NOTE: Certain internal components are implemented as described in NIST
  SP 800-90A/B/C but they do NOT strictly conform to the standard nor
  they are intended to.  Standard requires extensive documentation and
  testing.

This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

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

---

Top Contributors

[![mwgamera](https://avatars.githubusercontent.com/u/903892?v=4)](https://github.com/mwgamera "mwgamera (20 commits)")

### Embed Badge

![Health badge](/badges/klg-random/health.svg)

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

PHPackages © 2026

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