phlak/strgen

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

1.4.1 2017-07-16 19:14 UTC

README

Latest Stable Version Total Downloads Author License Build Status StyleCI

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

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

Requirements

Install with Composer

composer require phlak/strgen

Usage

// Import StrGen
use StrGen\Generator;

// Initialize the Generator
$generator = new 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 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 Generator('0123456789abcdef');

Changelog

A list of changes can be found on the GitHub Releases page.

Troubleshooting

Please report bugs to the GitHub Issue Tracker.

Copyright

This project is licensed under the MIT License.