PHPackages                             ucscode/keygenerator - 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. ucscode/keygenerator

ActiveLibrary

ucscode/keygenerator
====================

(Ucscode) KeyGenerator is a versatile PHP library for generating random keys of varying lengths. It is an essential tool for creating secure authentication tokens, unique identifiers, or random access keys.

v1.1.0(1y ago)0113↓100%1MITPHPPHP &gt;=8.1

Since Apr 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ucscode/Key-Generator)[ Packagist](https://packagist.org/packages/ucscode/keygenerator)[ RSS](/packages/ucscode-keygenerator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (1)

PHP Random KeyGenerator
=======================

[](#php-random-keygenerator)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/ucscode/keygenerator/blob/main/LICENSE)[![PHP Version](https://camo.githubusercontent.com/0926502643da3f215feaccd3643d5be697009565f111a6b3d6fc61d082c05f2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f756373636f64652f6b657967656e657261746f72)](https://php.net)

PHP Random KeyGenerator is a versatile PHP library for generating random keys of varying lengths. It is an essential tool for creating secure authentication tokens, unique identifiers, or random access keys.

Features
--------

[](#features)

- **Versatile Usage**: Can be used for various purposes such as generating authentication tokens, unique identifiers, or random access keys.
- **Simplicity**: Provides a simple and easy-to-use interface, making it straightforward to integrate into your projects.
- **Modern PHP Compatibility**: Compatible with PHP 8.1 and higher, ensuring compatibility with modern PHP environments.
- **PSR-4 Autoloading**: Follows PSR-4 autoloading standards for seamless integration with Composer-based projects.

Direct Installation
-------------------

[](#direct-installation)

You can require the file in your project directly:

```
require '/path/to/src/KeyGenerator.php';
```

Installation Via Composer
-------------------------

[](#installation-via-composer)

You can also install the package via Composer. Run the following command:

```
composer require ucscode/keygenerator
```

Usage
-----

[](#usage)

```
use Ucscode\KeyGenerator\KeyGenerator;

// Create a new instance of the key generator
$keyGenerator = new KeyGenerator();

// Generate a random key of length 10
$key = $keyGenerator->generateKey(10);

// Generate a random key with prefix and suffix
$key = $keyGenerator->generateKey(5, 'app-', '-volvo');

echo $key; // app-SNb9P-volvo
```

### Instance Configuration

[](#instance-configuration)

Optionally, you can configure the `KeyGenerator` instance

```
/**
 * Generate random keys between 'A' and 'Z'
 *
 * @param string|array
 */
$keyGenerator->setCharacters(range('A', 'Z'));

/**
 * This will also generate random keys between 'A' and 'Z'
 *
 * @param string|array
 */
$keyGenerator->setCharacters('ABCDEFGHIJKLMNOPQRSTUVWXYZ');

/**
 * Add more possible characters to the list of generated keys
 *
 * @param string|array
 */
$keyGenerator->addCharacters(['#', '@', '%']);

/**
 * Remove one or more character from the list
 *
 * The "@" symbol will not be part of possible value from the characters
 *
 * @param string|array
 */
$keyGenerator->removeCharacters('@');

/**
 * Apply usage of the system default special characters
 *
 * By default, if no configuration is made, the key generator will only contain alpha numeric outputs
 *
 * @param bool
 */
$keyGenerator->applySpecialCharacters(true);
```

License
-------

[](#license)

Ucscode KeyGenerator is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Support
-------

[](#support)

If you encounter any issues or have questions regarding the usage of this package, please feel free to [open an issue](https://github.com/ucscode/keygenerator/issues) on GitHub.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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.

###  Release Activity

Cadence

Every ~86 days

Total

3

Last Release

568d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65673b1b31e87471999a7614d107e7e061a38bf72191d149c66c1b943124e09c?d=identicon)[ucscode](/maintainers/ucscode)

---

Top Contributors

[![ucscode](https://avatars.githubusercontent.com/u/34024404?v=4)](https://github.com/ucscode "ucscode (5 commits)")

### Embed Badge

![Health badge](/badges/ucscode-keygenerator/health.svg)

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

PHPackages © 2026

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