2017 © Pedro Peláez
 

library strgen

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

image

phlak/strgen

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

  • Sunday, May 27, 2018
  • by PHLAK
  • Repository
  • 3 Watchers
  • 6 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 11 Versions
  • 11 % Grown

The README.md

StrGen , (*1)

Join the Community Become a Sponsor One-time Donation
Latest Stable Version Total Downloads License , (*2)

PHP library for simple secure random string generation (e.g. - passwords / salts)
Created by Chris Kankiewicz (@PHLAK) , (*3)


Requirements

Install with Composer

composer require phlak/strgen

Usage

// Import StrGen
use PHLAK\StrGen;

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

// Generate a random string of characters
$generator->length(16)->generate(); // 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 a character set or an array of sets to the charset() method., (*4)

Example using built-in sets:, (*5)

$generator = new StrGen\Generator();

$generator->charset(StrGen\CharSet::ALPHA_NUMERIC)->generate();

// or

$generator->charset([StrGen\CharSet::MIXED_ALPHA, StrGen\CharSet::NUMERIC])->generate();

Available presets:, (*6)

Key Character Set
StrGen\CharSet::LOWER_ALPHA abcdefghijklmnopqrstuvwxyz
StrGen\CharSet::UPPER_ALPHA ABCDEFGHIJKLMNOPQRSTUVWXYZ
StrGen\CharSet::MIXED_ALPHA abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
StrGen\CharSet::NUMERIC 0123456789
StrGen\CharSet::ALPHA_NUMERIC abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
StrGen\CharSet::SPECIAL !@#$%^&*()-_=+.?{}[]<>:;/\\|~
StrGen\CharSet::ALL abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
!@#$%^&*()-_=+.?{}[]<>:;/\\|~

Custom sets:, (*7)

You can also manually define a character set by passing a string of characters to the charset() method., (*8)

$generator = new StrGen\Generator();

$generator->charset('0123456789abcdef')->generate();

Convenience Functions

StrGen also has built-in convenience functions for generating strings from the included character sets or a custom character set., (*9)

$generator->lowerAlpha($length);
$generator->upperAlpha($length);
$generator->mixedAlpha($length);
$generator->numeric($length);
$generator->alphaNumeric($length);
$generator->special($length);
$generator->all($length);
$generator->custom($length, $charset);

Changelog

A list of changes can be found on the GitHub Releases page., (*10)

Troubleshooting

For general help and support join our Spectrum community., (*11)

Please report bugs to the GitHub Issue Tracker., (*12)

This project is licensed under the MIT License., (*13)

The Versions

27/05 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

password string generation salt

25/01 2018

3.0.0

3.0.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

password string generation salt

24/01 2018

dev-next

dev-next

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

password string generation salt

06/09 2017

2.0.0

2.0.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

password string generation salt

16/07 2017

1.4.1

1.4.1.0

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

password string generation salt

26/05 2017

1.4.0

1.4.0.0

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

password string generation salt

08/04 2016

1.3.0.x-dev

1.3.0.9999999-dev

Generate random strings (passwords / salts)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

password string generation salt

08/04 2016

1.3.0

1.3.0.0

Generate random strings (passwords / salts)

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

password string generation salt

14/03 2016

1.2.0

1.2.0.0

Generate random strings (passwords / salts)

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

password string generation salt

09/05 2014

1.1.0

1.1.0.0

Generate random strings (passwords / salts)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

password string generation salt

05/05 2014

1.0.0

1.0.0.0

Generate random strings

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

password string generation salt