2017 © Pedro Peláez
 

library randomorg

PHP class and Laravel implementation for Random.org

image

defiant/randomorg

PHP class and Laravel implementation for Random.org

  • Monday, October 24, 2016
  • by defiant
  • Repository
  • 3 Watchers
  • 13 Stars
  • 923 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

randomorg

Native PHP and Laravel Implementation of Random.org's JSON-RPC API, (*1)

Installation with Composer

composer require defiant/randomorg

or add it in your composer.json require block., (*2)

{
    "require": {
        "defiant/randomorg": "1.*"
    }
}

and, (*3)

composer update

Native PHP Usage

$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']);

Laravel Usage

  • Register service provider in your config/app.php file.
RandomOrg\RandomServiceProvider::class
  • Register the RandomOrg facade in the aliases key of your config/app.php
'RandomOrg' => RandomOrg\Facades\Random::class,
  • Run a vendor:publish artisan command to publish your configuration assets to config/randomorg.php
$ php artisan vendor:publish --provider="RandomOrg\RandomServiceProvider"

You may set your API key directly in your config/randomorg.php file or in your .env file like so:, (*4)

RANDOM_ORG_API_KEY=00000000-0000-0000-0000-000000000000

Example code:, (*5)

use RandomOrg;

public function random()
{
    return RandomOrg::generateIntegers(52, 1, 52, false);
}

About API Keys

You can get your own API key at https://api.random.org/api-keys, (*6)

Api Key (00000000-0000-0000-0000-000000000000) used in these examples will be disabled when the beta ends. Get your API key at https://api.random.org/api-keys, (*7)

For the native implementation, there are three methods where you can set the API key in your class., (*8)

First in the constructor:, (*9)

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

Secondly you can set it directly your class, (*10)

protected $apiKey = '00000000-0000-0000-0000-000000000000';

or you can use the setApi method, (*11)

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

Note: Method names are the same with simple method names on the API. To make signed request an optional boolean parameter is needed as the final argument., (*12)

Currently supports simple and signed methods below. For more information see https://api.random.org/json-rpc/1/, (*13)

  • generateIntegers
  • generateDecimalFractions
  • generateGaussians
  • generateStrings
  • generateUUIDs
  • generateBlobs
  • getUsage
  • generateSignedIntegers
  • generateSignedDecimalFractions
  • generateSignedGaussians
  • generateSignedStrings
  • generateSignedUUIDs
  • generateSignedBlobs
  • verifySignature

The Versions

24/10 2016

dev-master

9999999-dev http://github.com/defiant/randomorg

PHP class and Laravel implementation for Random.org

  Sources   Download

The Requires

 

The Development Requires

random random.org

24/10 2016

v1.0.0

1.0.0.0 http://github.com/defiant/randomorg

PHP class and Laravel implementation for Random.org

  Sources   Download

The Requires

 

The Development Requires

random random.org