PHP code example of saacsos / randomgenerator

1. Go to this page and download the library: Download saacsos/randomgenerator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saacsos / randomgenerator example snippets



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();




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



$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

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

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

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