Overview
  • Class

Classes

  • P2PEG

Functions

  • sys_get_temp_dir

Class P2PEG

Located at

Methods summary

public static
# instance( $secret = NULL )
public
# __construct( $secret = ',!8L_J:UW~l\'ACt:7c05!R9}~>yb!gPP=|(@FBny\'ao/&-\jVs' )
public
# __destruct( )
public
# saveState( $sf = NULL )
public
# warmup( $secret = NULL )
public
# seed( $seed = NULL )

Seed P2PEG with some entropy.

Seed P2PEG with some entropy.

public
# str( $len = NULL )

Return a random binary string of specified length.

Return a random binary string of specified length.

public
# hex( $len = NULL )

Hex encoded string

Hex encoded string

public
# text( $len = NULL )

Base64 encoded text for URL

Base64 encoded text for URL

public (int)random
# int16( )

Return a random 16 bit integer.

Return a random 16 bit integer.

Returns

(int)random
public (int)random
# int32( )

Return a random 32 bit integer.

Return a random 32 bit integer.

Returns

(int)random
public (int)random
# int( (int)$size $size = NULL )

Return a random integer.

Return a random integer.

Parameters

$size

number of bytes used to generate the integer [1..PHP_INT_SIZE]. Defaults to PHP_INT_SIZE (4 or 8, depending on system) Ex. If $size == 1, the result is a number from interval [0..255]. If $size == 3, the result is a number from interval [0..16777215].

Returns

(int)random
public (int)random
# rand32( )

Pseudo-random 32bit integer numbers generator.

Pseudo-random 32bit integer numbers generator.

This function produces same result as $this->int32(), but is much faster at generating long strings of random numbers, and uses less entropy as well.

Returns

(int)random

Source

http://en.wikipedia.org/wiki/Random_number_generation
public (int)random
# rand64( )

Pseudo-random 64bit integer numbers generator.

Pseudo-random 64bit integer numbers generator.

Returns

(int)random

Source

http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
public
# servImg( (int)$width $width = 64, (int)$height $height = 64, (str)$meth $meth = 'rand32', (int)$itemSize $itemSize = NULL )

Generate and serve to client a random bitmap image.

Generate and serve to client a random bitmap image.

This method helps to visually inspect a random number generator (RNG). It is not enough to know how good the RNG is, but it can tell that the RNG is bad or something is wrong.

Parameters

$width
the image
$height
the image
$meth
a method of this class to generate data
$itemSize
bits - size of each number or char generated by $meth. Defaults to 8 for string and 32 for int

Note

Requires the GD Library

Inspired by http://boallen.com/random-numbers.html


public
# setSecret( $key )
public
# dynEntropy( $quick = true )

Quickly get some dynamic entropy.

Quickly get some dynamic entropy.

public
# clientEntropy( )
public
# serverEntropy( )
public
# filesystemEntropy( $dirs = NULL, $maxRead = 0 )
public
# serverEEntropy( $autoseed = true )

Server Expensive entropy.

Server Expensive entropy.

Note: Contains serverEntropy()

public
# networkEntropy( $autoseed = true )
public
# expensiveEntropy( $autoseed = true )

Since this class is designed to run as quick as posible, this method is not called by default. * You should call this method only in places where speed is not critical (ex. on cron, in a background request)

Since this class is designed to run as quick as posible, this method is not called by default. * You should call this method only in places where speed is not critical (ex. on cron, in a background request)

public
# state( )
public
# hash( $str, $raw = true )
public
# packIP4( $ip )
public
# packInt( $int )
public
# packFloat( $float )
public
# bin2text( $bin )
public
# text2bin( $text, $strict = false )
public
# strxor( $a, $b )
public
# env( $n )
public
# seedRandomDev( $seed = NULL )

Write some random bits to /dev/random or /dev/urandom

Write some random bits to /dev/random or /dev/urandom

From man 4 random: Writing to /dev/random or /dev/urandom will update the entropy pool with the data written, but this will not result in a higher entropy count. This means that it will impact the contents read from both files, but it will not make reads from /dev/random faster.

public
# frand_put_content( $filename, $length = NULL, $append = false )

Write $length bytes of random data to $filename file.

Write $length bytes of random data to $filename file.

If $length is not specified, write data from internal buffer.

public true
# do_flock( (resource)$fp $fp, (int) $lock, (int) $timeout_ms = 384 )

Lock with retries

Lock with retries

Parameters

$fp
Open file pointer
$lock
  • Lock type
$timeout_ms
  • Timeout to wait for unlock in miliseconds

Returns

true
on success, false on fail

Author

Dumitru Uzun
public
# flock_put_contents( $fn, $cnt, $block = false )
public
# flock_get_contents( $fn, $block = false )
public
# isWindows( )

Properties summary

public static string $version
# '0.3.5'
public static $start_ts
#
protected static $instance
#
public $state_file
#
public boolean $debug
# false
public array $hash
# array('sha512', 'sha256', 'sha128', 'sha1', 'md5')
public boolean $seedSys
# true
public integer $rs00
# 0
public integer $rs01
# 0
public integer $rs10
# 0
public integer $rs11
# 0
protected $_state_mtime
#
protected $_clientEntropy
#
protected $_serverEntropy
#
protected $_serverEEntropy
#
protected $_filesystemEntropy
#
protected static $int_len
#
API documentation generated by ApiGen