PHP code example of defiant / randomorg

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

    

defiant / randomorg example snippets


$apiKey = '00000000-0000-0000-0000-000000000000';
$random = new RandomOrg\Random($apiKey);

// Simple method
// following functions returns 52 random non-repeating numbers between 1-52

$result = $random->generateIntegers(52, 1, 52, false);

// Signed methods
// following functions returns the above with signed data
$result = $random->generateIntegers(52, 1, 52, false, 10, true);

// Verify Signature
$verified = $random->verifySignature($result['result']['random'], $result['result']['signature']);

RandomOrg\RandomServiceProvider::class

'RandomOrg' => RandomOrg\Facades\Random::class,

use RandomOrg;

public function random()
{
    return RandomOrg::generateIntegers(52, 1, 52, false);
}
bash
$ php artisan vendor:publish --provider="RandomOrg\RandomServiceProvider"