Skip to content

Commit e9fde7f

Browse files
committed
update documentation
1 parent ab9776e commit e9fde7f

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ Optionally you can specify *wordCacheFile* to control the location and name of t
7979

8080
To a custom instance you can pass an optional boolean parameter *fetch*. When false, the cached wordlist will be preferred but falls back to fetching if it could not be loaded.
8181

82-
You can also mix different RSS sources into the same wordlist file with the `appendWordlist` parameter, increasing entropy, or regularly rebuild your cache file from time to time to feed it with new words. Altought having more words is always desirable,
83-
you can limit the number of items in the wordlist with the `limitWordlist` configuration parameter. When using append, wordlist is shuffled before being limited to the desired quantity.
84-
8582
```php
8683
include 'PasswordGenerator.php';
8784

@@ -93,8 +90,16 @@ $gen = PasswordGenerator::EN();
9390
echo 'Password 1: ', $gen->generate();
9491
echo 'Password 2: ', $gen->generate();
9592
echo 'Password 3: ', $gen->generate();
93+
```
94+
95+
When fetching an RSS source the normal behaviour is to create a new list, overwriting an existing cache file. You can opt-in to merge the new wordlist with an exisiting cache file instead, by setting the `appendWordlist` parameter to true. On the one hand this will result in bigger word lists, increasing entropy, on the other hand this may lead to very long lists. You can limit the number of items in the wordlist with the `limitWordlist` configuration parameter. When using this option and the wordlist is exceeding that limit, it is shuffled and then sliced to that number.
96+
97+
```php
98+
include 'PasswordGenerator.php';
99+
100+
use \Darkv\PhpPasswordGenerator\PasswordGenerator;
96101

97-
// Append NYTimes feed to the specified wordlist, limiting to 7000 items max
102+
// append NYTimes feed to the specified wordlist, limiting to 7000 items max
98103
$gen = new PasswordGenerator([
99104
'wordCacheFile' => 'mywords.json',
100105
'url' => 'https://rss.nytimes.com/services/xml/rss/nyt/World.xml',
@@ -170,11 +175,11 @@ When creating an instance of PasswordGenerator you can provide the following par
170175

171176
* **appendWordlist**
172177

173-
If true, the fetched wordlist will be appended to the current one. If false, wordlist is generated from scratch.
178+
If true, the fetched wordlist will be appended to an existing cache file. If false, cache will be overwritten.
174179

175180
* **limitWordlist**
176181

177-
Int value declaring the maximum words the wordlist must contain. Useful when using appendWordList.
182+
Int value declaring the maximum number if words the wordlist may contain. Useful when using appendWordList.
178183

179184

180185
## License

example/PasswordGenerator.example.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// generate a password with custom pattern
5353
echo $gen->generate('wiwsw'), "\n";
5454

55-
// Append NYTimes feed to the last wordlist, limiting to 700 items max
55+
// append NYTimes feed to the existing cache file, limiting to 700 items max
5656
$gen = new PasswordGenerator([
5757
'wordCacheFile' => 'mywords.json',
5858
'url' => 'https://rss.nytimes.com/services/xml/rss/nyt/World.xml',

src/PasswordGenerator.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ class PasswordGenerator
7272
* <dt>wordCacheFile</dt>
7373
* <dd>Filename of the cache file.</dd>
7474
* <dt>appendWordlist</dt>
75-
* <dd>If true, the fetched wordlist will be appended to the current one. If false, wordlist is generated from scratch.</dd>
75+
* <dd>If true, the fetched wordlist will be appended to the an existing
76+
* one. If false, wordlist is generated from scratch.</dd>
7677
* <dt>limitWordlist</dt>
77-
* <dd>Int value declaring the maximum words the wordlist must contain. Useful when using appendWordList.</dd>
78+
* <dd>Int value declaring the maximum number of words the wordlist may
79+
* contain. Useful when using appendWordList.</dd>
7880
* <dt>httpRedirects</dt>
7981
* <dd>Number of maximum HTTP redirects the script will follow.</dd>
8082
* </dl>

0 commit comments

Comments
 (0)