You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`wordSeparator`|`?string`|`'-'`| Character(s) between words. `null` uses instance/config default. |
117
117
|`capitalize`|`?bool`|`false`| Capitalize the first letter of each word. `null` uses instance/config default. |
118
118
|`includeNumber`|`?bool`|`false`| Append a random digit (0–9) to one random word. `null` uses instance/config default. |
119
+
|`targetEntropyBits`|`?int`|`null`| Optional. Adjusts word count to meet or exceed this entropy target (in bits). Overrides `numWords` when set. |
119
120
120
-
All parameters are nullable — passing `null` (or omitting them) uses the defaults set via `setDefaults()` or `config/passphrase.php` in Laravel.
121
+
All `generate()` parameters are nullable. For `numWords`, `wordSeparator`, `capitalize`, and `includeNumber`, passing `null` (or omitting them) uses defaults set via `setDefaults()` or `config/passphrase.php` in Laravel.
122
+
123
+
`targetEntropyBits` is evaluated per-call by `generate()` and is not loaded from `setDefaults()` (there is currently no `target_entropy_bits` config key).
124
+
125
+
When calling `generate()`, providing `targetEntropyBits` takes precedence over `numWords`.
126
+
127
+
```php
128
+
$generator = new PassphraseGenerator();
129
+
130
+
// Entropy-based generation: numWords is calculated to reach at least 60 bits
131
+
echo $generator->generate(targetEntropyBits: 60);
132
+
```
121
133
122
134
These match [Bitwarden's passphrase generator options](https://bitwarden.com/passphrase-generator/) exactly.
123
135
@@ -138,6 +150,8 @@ return [
138
150
'capitalize' => false,
139
151
'include_number' => false,
140
152
153
+
// No 'target_entropy_bits' key: targetEntropyBits is a per-call generate() override
154
+
141
155
// null = bundled EFF long word list (7,776 words)
142
156
// Or provide your own word list as a PHP array of strings
143
157
'word_list' => null,
@@ -148,7 +162,9 @@ return [
148
162
];
149
163
```
150
164
151
-
These config values are automatically used as defaults when calling `Passphrase::generate()` without explicit parameters. You can still override any option per-call.
165
+
These config values are wired into `PassphraseGenerator::setDefaults()` and are automatically used as defaults when calling `Passphrase::generate()` without explicit parameters.
166
+
167
+
`targetEntropyBits` is not part of `setDefaults()` and therefore has no `target_entropy_bits` config key; pass it directly to `generate()` when you want entropy-targeted generation.
0 commit comments