PHP Classes


Recommend this page to a friend!
  Classes of Pierre-Henry Soria   PHP Passcode and Password Generator   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Passcode and Password Generator
Generate password strings that follow rules
Author: By
Last change:
Date: 4 months ago
Size: 2,589 bytes


Class file image Download

PHP Passcodes & Passwords Generator

? Description

A simple & clean way to generate random passcodes and passwords ?

Ko Fi - Offer Me A Coffee

? Server Requirement

? Installation (with Composer)

composer require ph-7/passcode-password-generator

? Usage

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

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?

Pierre-Henry Soria

[![@phenrysay][twitter-image]]( [![pH-7][github-image]](

Pierre-Henry Soria, a highly passionate, zen & pragmatic software engineer ?

?? ?Would like to help? Offer me a coffee and boost the software development at the same time! ?

?? License

PHP Passcode/Password Generator is generously distributed under the MIT ?

<!-- GitHub's Markdown reference links --> [twitter-image]: [github-image]: