Random string generation library.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
src
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

StrGen

Latest Stable Version Total Downloads Author License Build Status

Generate secure random strings (e.g. - passwords / salts).

Like this project? Keep me caffeinated by making a donation.

Install with Composer

composer require phlak/strgen

Example Usage

// Import StrGen
use StrGen;

// Initialize the Generator
$generator = new StrGen\Generator();

// Generate a random string of characters
$password = $generator->generate(16); // Returns something like '8a*Ag@I0*s0v[S3u'

Character Sets

StrGen has a few built-in character sets available for ease of use. You can specify which set(s) to use by passing an array of set names to the StrGen class:

Example using built-in sets:

$generator = new StrGen\Generator(['lower', 'upper', 'numeric']);

Available presets:

Key Character Set
lower abcdefghijklmnopqrstuvwxyz
upper ABCDEFGHIJKLMNOPQRSTUVWXYZ
numeric 0123456789
special !@#$%^&*()-_=+.?
extra {}[]<>:;/\|~

Custom sets:

You can also manually define a character set by passing a string of characters to the StrGen class:

$generator = new StrGen\Generator('0123456789abcdef');

Troubleshooting

Please report bugs to the GitHub Issue Tracker.

Copyright

This project is liscensed under the MIT License.