Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added PHP syntax highlighting.
  • Loading branch information
gajus committed Feb 27, 2014
1 parent 93933ac commit f1f04ce
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ Usage

A factory is used to get generators of varying strength:

$factory = new RandomLib\Factory;
$generator = $factory->getGenerator(new SecurityLib\Strength(SecurityLib\Strength::MEDIUM));
```php
$factory = new RandomLib\Factory;
$generator = $factory->getGenerator(new SecurityLib\Strength(SecurityLib\Strength::MEDIUM));
```

A factory can be configured with additional mixers and sources but can be
used out of the box to create both medium and low strength generators.

Convenience methods are provided for creating high, medium, and low
strength generators. Example:

$generator = $factory->getMediumStrengthGenerator();

```php
$generator = $factory->getMediumStrengthGenerator();
```

#### $factory->getLowStrengthGenerator()

Expand Down Expand Up @@ -62,16 +65,17 @@ A generator is used to generate random numbers and strings.

Example:

// Generate a random string that is 32 bytes in length.
$bytes = $generator->generate(32);

// Generate a whole number between 5 and 15.
$randomInt = $generator->generateInt(5, 15);
```php
// Generate a random string that is 32 bytes in length.
$bytes = $generator->generate(32);

// Generate a 32 character string that only contains the letters
// 'a', 'b', 'c', 'd', 'e', and 'f'.
$randomString = $generator->generateString(32, 'abcdef');
// Generate a whole number between 5 and 15.
$randomInt = $generator->generateInt(5, 15);

// Generate a 32 character string that only contains the letters
// 'a', 'b', 'c', 'd', 'e', and 'f'.
$randomString = $generator->generateString(32, 'abcdef');
```

#### $generator->generate($size)

Expand All @@ -98,18 +102,19 @@ If no character list is specified, the following list of characters is used:

**Examples:**

// Give the character list 'abcdef':
print $generator->generateString(32, 'abcdef')."\n";

// One would expect to receive output that only contained those
// characters:
//
// adaeabecfbddcdaeedaedfbbcdccccfe
// adfbfdbfddadbfcbbefebcacbefafffa
// ceeadbcabecbccacdcaabbdccfadbafe
// abadcffabdcacdbcbafcaecabafcdbbf
// dbdbddacdeaceabfaefcbfafebcacdca

```php
// Give the character list 'abcdef':
print $generator->generateString(32, 'abcdef')."\n";

// One would expect to receive output that only contained those
// characters:
//
// adaeabecfbddcdaeedaedfbbcdccccfe
// adfbfdbfddadbfcbbefebcacbefafffa
// ceeadbcabecbccacdcaabbdccfadbafe
// abadcffabdcacdbcbafcaecabafcdbbf
// dbdbddacdeaceabfaefcbfafebcacdca
```

License
-------
Expand Down

0 comments on commit f1f04ce

Please sign in to comment.