Class RandSource

Description

This class provides random data in serveral forms.

The supported forms include:

  • Numbers of arbitiary range (also floats available via exponent)
  • Strings of arbitiary length (for which you may decide what kind of characters they may contain)
  • Binary data of arbitiary length
  • Base64 style data

Located in /phpsatk-lib/global/org.eenterphace.sat.crypto.rand/rand.source.php (line 39)


	
			
Method Summary
string getBase64 (int $length)
string getBinary (int $bytes)
int/float getNumber (int $min, [int $max = 65000], int $exponent)
string getString (int $length, [boolean $special = true], [boolean $nums = true], [boolean $alpha = true])
Methods
getBase64 (line 110)

Gets a random base64 string

This function is useful when building salts for base64 encoded hashes

  • access: public
  • static:
string getBase64 (int $length)
  • int $length: Length
getBinary (line 129)

Gets random binary data

This function returns non-printable characters!!

  • access: public
  • static:
string getBinary (int $bytes)
  • int $bytes: Number of bytes to return
getNumber (line 56)

Generates a (pseudo) Random Number

This function is the datasource for the other functions. You might pass an exponent to create floating point numbers:

  1. RandSource::getNumber(0,1000, -3);
  2. // -> will return a random number between 0 and 1 with three decimals

  • access: public
  • static:
int/float getNumber (int $min, [int $max = 65000], int $exponent)
  • int $min: Minimum Value
  • int $max: Maxmimum Value
  • int $exponent: Exponent for base 10 multiplied with the result
getString (line 75)

Fetches a random string of given length

Does not work on multi-byte characters.

Special characters do not include chars not found on a standard keyboard as well as characters which usually cause trouble when typing them. (maybe this is not true for some keyboard layouts -> TELL ME)

  • access: public
  • static:
string getString (int $length, [boolean $special = true], [boolean $nums = true], [boolean $alpha = true])
  • int $length: Length of string to build
  • boolean $special: Whether to include special characters
  • boolean $nums: Whether to include numbers
  • boolean $alpha: Whether to include alphanumerics

Documentation generated on Mon, 21 May 2007 10:35:14 +0200 by phpDocumentor 1.3.0RC5