2017 © Pedro Peláez
 

library randomgenerator

Generate Random String by level and length

image

saacsos/randomgenerator

Generate Random String by level and length

  • Monday, May 9, 2016
  • by saacsos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,166 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 9 % Grown

The README.md

saacsos/randomgenerator

Laravel 5 Custom String Random Generator, (*1)

Installation

$ composer require saacsos/randomgenerator

Basic Usage

<?php
use Saacsos\Randomgenerator\Util\RandomGenerator;

// Create an object
$randomGenerator = new RandomGenerator();

// Get random password
$randomGenerator->password();
$password = $randomGenerator->get();
// or
$password = $randomGenerator->password()->get();

// Get random access token (48 chars)
$accessToken = $randomGenerator->accessToken()->get();

Level & Length

Level of strength * 1 = number ([0-9]) * 2 = hexadecimal ([0-9a-f]) * 4 = lowercase (a-z except i,l,o) * 8 = uppercase (A-Z except I,L,O) * 16 = special character !@#$%^&*()_=[]{}?, Combine level for complex password * 5 = 1 + 4 = number + lowercase * 13 = 1 + 4 + 8 = number + lowercase + uppercase * 29 = 1 + 4 + 8 + 16 = number + lowercase + uppercase + special character, (*2)

<?php

// get password 8 characters in level 5 
$password = $randomGenerator->level(5)->length(8)->password()->get();

Default level = 13, Default length = 8, (*3)

isMatch($string, $strict=false)

Validate if $string match the level or not Strict mode will check $string must has at least 1 character in its level, (*4)

<?php

$match = $randomGenerator->min(8)->max(8)->level(13)->isMatch('password'); // true
$match = $randomGenerator->min(8)->max(8)->level(13)->isMatch('password', true); // false because no uppercase

Laravel 5 Service Provider and Facades

Add your new provider to the providers array of config/app.php:, (*5)

    'providers' => [
        // ...
        Saacsos\Randomgenerator\ServiceProvider\RandomGeneratorServiceProvider::class,
        // ...
    ],

Add class alias to the aliases array of config/app.php:, (*6)

    'aliases' => [
        // ...
        'RandomGenerator' => Saacsos\Randomgenerator\Facades\RandomGenerator::class,
        // ...
    ],

And you can use, (*7)

    $password = \RandomGenerator::password()->get();

The Versions

09/05 2016

dev-master

9999999-dev

Generate Random String by level and length

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar saacsos

09/05 2016

v1.1.0

1.1.0.0

Generate Random String by level and length

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar saacsos

09/05 2016

dev-develop

dev-develop

Generate Random String by level and length

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar saacsos

09/05 2016

dev-feature/chaining

dev-feature/chaining

Generate Random String by level and length

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar saacsos

08/05 2016

v1.0.0

1.0.0.0

Random Generator

  Sources   Download

MIT

by Avatar saacsos