PHPackages                             ph-7/passcode-password-generator - 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. [Security](/categories/security)
4. /
5. ph-7/passcode-password-generator

ActiveLibrary[Security](/categories/security)

ph-7/passcode-password-generator
================================

A simple way to generate random cryptographically secure passcodes and passwords

v2.0.9(1y ago)1223.4k—5%32MITPHPPHP &gt;=7.3.0CI failing

Since Sep 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pH-7/passcode-password-generator)[ Packagist](https://packagist.org/packages/ph-7/passcode-password-generator)[ Docs](https://pierrehenry.be)[ GitHub Sponsors](https://github.com/pH-7)[ Fund](https://ko-fi.com/phenry)[ RSS](/packages/ph-7-passcode-password-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (11)Used By (2)

PHP Passcodes &amp; Passwords Generator
=======================================

[](#php-passcodes--passwords-generator)

📄 Description
-------------

[](#-description)

*A simple, secure &amp; clean way to generate random **passcodes** and **passwords** 🔑*

The library generates cryptographically secure random passwords and passcodes.

[![Ko Fi - Offer Me A Coffee](media/kofi-logo.png)](https://ko-fi.com/phenry)

🛠 Server Requirement
--------------------

[](#-server-requirement)

- [PHP 7.3](https://php.net/releases/7_3_0.php) and higher 🚀

🛠 Installation (with Composer)
------------------------------

[](#-installation-with-composer)

```
composer require ph-7/passcode-password-generator
```

📄 Usage
-------

[](#-usage)

### For Passcodes

[](#for-passcodes)

```
use PH7\Generator\Passcode;

echo Passcode::generate(10); // Generate a 10-length passcode
```

By default, without argument, the function will generate a 6-character passcode.

```
use PH7\Generator\Passcode;

// By default, it generates a 6 length passcode
echo Passcode::generate();

// You can use the public `Passcode::DEFAULT_LENGTH` const, whcih also gives a 6-length passcode
echo Passcode::generate(Passcode::DEFAULT_LENGTH);
```

### For Passwords

[](#for-passwords)

```
use PH7\Generator\Password;

echo Password::generate(16); // Generate a 16-length password
```

By default, generated passwords will contain special characters. You can disable them by mentioning the second argument to `false`

```
use PH7\Generator\Password;

// The password won't contain any special characters such as -, _, ~, |, %, ^, !, $, #, @, and ?
echo Password::generate(Password::DEFAULT_LENGTH, false);
```

Without argument, the function will generate a 12-character password.

```
use PH7\Generator\Password;

// By default, it generates a 12-length password
echo Password::generate();

// Password::DEFAULT_LENGTH also gives a 12-length password
echo Password::generate(Password::DEFAULT_LENGTH);
```

😋 Who cooked it?
----------------

[](#-who-cooked-it)

[![Pierre-Henry Soria](https://camo.githubusercontent.com/2e624b95003073bd56ecb43792155201b96f2e1d11bab1218e2215b6238c6ac2/68747470733a2f2f732e67726176617461722e636f6d2f6176617461722f61323130666536313235336334336338363964373165616564306539303134393f733d323030)](https://ph7.me "Pierre-Henry Soria personal website")

[![@phenrysay](https://camo.githubusercontent.com/48ec885ab368ddc9f242022a409527d7ae3e9f3e754d0fbeaa77f3f03de546bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f782d3030303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d78266c6f676f436f6c6f723d7768697465)](https://x.com/phenrysay) [![pH-7](https://camo.githubusercontent.com/4fcd516e2fde608afc9ddd1330de295d23981c27a9b9d695f8abe51f70a1efc5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d3130303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.com/pH-7) [![YouTube Tech Videos](https://camo.githubusercontent.com/6690f404cb91efe3927127c7dae40ed4f401c7d6fbe3ad3635b7ad9ba0b370c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f596f75547562652d4646303030303f7374796c653d666f722d7468652d6261646765266c6f676f3d796f7574756265266c6f676f436f6c6f723d7768697465)](https://www.youtube.com/@pH7Programming "My YouTube Tech Channel")

**[Pierre-Henry Soria](https://ph7.me)**, a highly passionate, zen &amp; pragmatic software engineer 😊

☕️ Would like to help? **[Offer me a coffee](https://ko-fi.com/phenry)**, and boost the maintenance of this library! 💪

⚖️ License
----------

[](#️-license)

**PHP Passcode/Password Generator** is generously distributed under the *[MIT](https://opensource.org/licenses/MIT)* 🎉

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance44

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% 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 ~139 days

Recently: every ~276 days

Total

10

Last Release

444d ago

Major Versions

v1.0.0 → v2.0.02021-09-29

PHP version history (2 changes)v1.0.0PHP &gt;=7.1.0

v2.0.5PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6d95da236687f1dca4f7d70d60037c70ef217120ea195df23a39a412ba594e0?d=identicon)[ph-7](/maintainers/ph-7)

---

Top Contributors

[![pH-7](https://avatars.githubusercontent.com/u/1325411?v=4)](https://github.com/pH-7 "pH-7 (72 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![lemmon](https://avatars.githubusercontent.com/u/251591?v=4)](https://github.com/lemmon "lemmon (1 commits)")

---

Tags

cryptographically-securecryptographically-secure-randomcryptographypasscodepasscode-generatorpasscode-generator-phppassword-generatorpassword-generator-phpphprandom-passcoderandom-passcode-generatorrandom-passwordrandom-password-generatorsecuritycryptographypasswordgeneratorcryptographically securepassword generatordigitdigitspasscodepasscode generator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ph-7-passcode-password-generator/health.svg)

```
[![Health](https://phpackages.com/badges/ph-7-passcode-password-generator/health.svg)](https://phpackages.com/packages/ph-7-passcode-password-generator)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[rych/phpass

PHP Password Library: Easy, secure password management for PHP

248801.7k4](/packages/rych-phpass)[bordoni/phpass

Portable PHP password hashing framework

244.4M26](/packages/bordoni-phpass)[jeremykendall/password-validator

Password Validator validates password\_hash generated passwords, rehashes passwords as necessary, and will upgrade legacy passwords.

14469.9k3](/packages/jeremykendall-password-validator)[xxtea/xxtea

XXTEA is a fast and secure encryption algorithm. This is a XXTEA library for PHP.

11341.7k](/packages/xxtea-xxtea)

PHPackages © 2026

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