PHP code example of elcodedocle / cryptosecureprng

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

    

elcodedocle / cryptosecureprng example snippets



$secGen =  new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG();
$randInt = $secGen->rand(); //between 0 and mt_getrandmax()
$randInt = $secGen->rand(1,100); //between 1 and 100
$randInt = $secGen->rand(-50,50); //between -50 and 50


$secGen =  new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG();
$stringLength = 20; // number of random chars to be generated
$stringOfRandomChars = $secGen->getRandomBytesString($stringLength); // generate a string of $stringLength random ascii chars (non printable too)


// PHP code, uses cryptosecureprng rand() to generate the samples
CryptoSecurePRNG();
$out=''; 
for ($i=0;$i<1280;$i++) for ($j=0;$j<720;$j++) { 
  $out .= $prng->rand(0,255).','.$prng->rand(0,255).','.$prng->rand(0,255).',';   
}
$fh = fopen('testout.txt','w');
fwrite ($fh, $out);
fclose($fh);