PHP code example of germania-kg / random

1. Go to this page and download the library: Download germania-kg/random 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/ */

    

germania-kg / random example snippets



use Germania\Random\RandomServiceProvider;

// A. Use with Slim or Pimple
$app = new \Slim\App;
$dic = $app->getContainer();
$dic = new Pimple\Container;

// B. Register Service Provider.
// Optionally pass length and strenth:
$rsp = new RandomServiceProvider;
$rsp = new RandomServiceProvider( 240, 5);

$dic->register( $rsp  );

$generator = $dic['RandomGenerator'];
$str = $generator->generateString(32, 'abcdef');

$random_callable = $dic['RandomGenerator.Callable'];
$str = $random_callable(); // 256 characters
$str = $random_callable( 256 ); // 256 chars
$str = $random_callable( 64 ); // 64 chars.


$strength = $dic['RandomGenerator.Strength'];

$length = $dic['RandomGenerator.Length'];