2017 © Pedro Peláez
 

library phprandom

Just another random number/string generator for PHP 5

image

kijin/phprandom

Just another random number/string generator for PHP 5

  • Wednesday, September 24, 2014
  • by kijin
  • Repository
  • 1 Watchers
  • 6 Stars
  • 697 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

PHPRandom

Just another random number/string generator for PHP 5, (*1)

This library is similar to ircmaxell/RandomLib, except it is compatible with PHP 5.0 and above, and comes with a much simpler interface. Seriously, PHP ain't Java. Why do we need a dozen files and classes inheriting one another just to get some random bytes? :p, (*2)

How to Install

Traditional method:, (*3)

include 'phprandom.php';

Composer:, (*4)

"require": {
    "kijin/phprandom": "dev-master"
}

How to Use

Get a random integer between two endpoints (inclusive):, (*5)

$random = PHPRandom::getInteger($min, $max);

Get a random floating-point number between 0 and 1:, (*6)

$random = PHPRandom::getFloat();

Get a random alphanumeric string (0-9, a-z, A-Z):, (*7)

$random = PHPRandom::getString($length);

Get a random hexademical string (0-9, a-f):, (*8)

$random = PHPRandom::getHexString($length);

Get a random binary string:, (*9)

$random = PHPRandom::getBinary($length);

Find out where your precious entropy comes from:, (*10)

$sources = PHPRandom::listSources();

Configuration

PHPRandom requires no configuration., (*11)

You don't have to choose whether you want low-quality or high-quality entropy. You always get the highest quality of entropy that your system supports. Since the marginal cost of asking for high-quality entropy is negligible in most cases, there is rarely any need to ask for low-quality entropy., (*12)

Weaker sources of entropy are automatically mixed with other sources using the best mixing algorithm that your system supports., (*13)

Supported sources, in order of preference:, (*14)

  • openssl_random_pseudo_bytes()
  • mcrypt_create_iv() with MCRYPT_DEV_URANDOM
  • mcrypt_create_iv() with MCRYPT_RAND (Windows only)
  • /dev/urandom (Linux/Unix only)
  • rand() xor mt_rand()

Supported mixers, in order of preference:, (*15)

  • hash_hmac() with SHA-256
  • sha1()

License

PHPRandom is free software released under the MIT license., (*16)

The Versions

24/09 2014

dev-master

9999999-dev https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random

24/09 2014

1.2.0

1.2.0.0 https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random

05/09 2014

1.1.0

1.1.0.0 https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random

24/08 2014

1.0.2

1.0.2.0 https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random

24/08 2014

1.0.1

1.0.1.0 https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random

21/08 2014

1.0.0

1.0.0.0 https://github.com/kijin/phprandom

Just another random number/string generator for PHP 5

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

random