Skip to content

Commit 3ed350e

Browse files
committed
Merge pull request #23 from robcaw/develop
Update default chars for generators
2 parents 816fc3a + 8d613f5 commit 3ed350e

4 files changed

Lines changed: 12 additions & 13 deletions

File tree

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,22 @@ vivait_string_generator:
4040
Generates a random string based on a pool or characters. Defaults:
4141

4242
```php
43-
@Generate(generator="string", options={"length"=8, "chars"="abcdefjhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345567890", "prefix"=""})
43+
@Generate(generator="string", options={"length"=8, "chars"="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "prefix"=""})
4444
```
4545

46-
47-
### `SecureBytesGenerator`
48-
Generates a secure random byte string using the `Symfony\Component\Security\Core\Util\SecureRandom` class. Defaults:
46+
### `SecureStringGenerator`
47+
Generates a secure random string using [ircmaxell's RandomLib](https://github.com/ircmaxell/RandomLib). The library provides three different strengths of
48+
strings(currently `high` is unavailable), `low` and `medium`. Defaults:
4949

5050
```php
51-
@Generate(generator="secure_bytes", options={"length"=8})
51+
@Generate(generator="secure_string", options={"length"=32, "chars"="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", "strength"="medium"})
5252
```
5353

54-
### `SecureStringGenerator`
55-
Generates a secure random string using [ircmaxell's RandomLib](https://github.com/ircmaxell/RandomLib). The library provides three different strengths of
56-
strings(currently `high` is unavailable), `low` and `medium`. Defaults:
54+
### `SecureBytesGenerator`
55+
Generates a secure random byte string using the `Symfony\Component\Security\Core\Util\SecureRandom` class. Defaults:
5756

5857
```php
59-
@Generate(generator="secure_string", options={"length"=32, "chars"="", "strength"="medium"})
58+
@Generate(generator="secure_bytes", options={"length"=8})
6059
```
6160

6261
## Usage

spec/Vivait/StringGeneratorBundle/Generator/SecureStringGeneratorSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function let(Factory $factory, Generator $low, Generator $medium)
3030

3131
$defaults = [
3232
'length' => 32,
33-
'chars' => '',
33+
'chars' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
3434
'strength' => 'medium',
3535
];
3636

@@ -59,7 +59,7 @@ function it_errors_on_invalid_strength_gen(Generator $medium, Generator $low)
5959

6060
function it_generates_a_random_string(Generator $medium)
6161
{
62-
$medium->generateString(32, '')->shouldBeCalled();
62+
$medium->generateString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')->shouldBeCalled();
6363
$this->generate();
6464
}
6565

src/Vivait/StringGeneratorBundle/Generator/SecureStringGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SecureStringGenerator implements ConfigurableGeneratorInterface
2020
*/
2121
private $generator;
2222

23-
private $chars = '';
23+
private $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
2424

2525
private $strength = 'medium';
2626

src/Vivait/StringGeneratorBundle/Generator/StringGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StringGenerator implements ConfigurableGeneratorInterface
1616
/**
1717
* @var string
1818
*/
19-
private $chars = 'abcdefjhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345567890';
19+
private $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
2020

2121
/**
2222
* @var string

0 commit comments

Comments
 (0)