Skip to content

feat: enhance passphrase generator with capitalize and number options#17

Draft
valerius21 wants to merge 1 commit intomainfrom
issue-14
Draft

feat: enhance passphrase generator with capitalize and number options#17
valerius21 wants to merge 1 commit intomainfrom
issue-14

Conversation

@valerius21
Copy link
Owner

Summary

Enhances the passphrase generator with two new security options for improved password complexity, closing #14.

  • Capitalize: randomly capitalizes each word with 50% probability (+1 bit entropy per word)
  • Add Numbers: inserts a random digit (0-9) between each pair of words (+3.32 bits entropy per digit)
  • Both options are exposed as checkboxes in the encrypt mode UI, next to the generate button
  • API is fully backward compatible — the legacy generatePassphrase(wordCount, separator) call style still works
  • passphraseEntropy() updated to accept options and account for the added entropy

Examples

Options Example Output Entropy
Default correct-horse-battery-staple-foo-bar ~77.5 bits
Capitalize Correct-horse-Battery-staple-Foo-bar ~83.5 bits
Numbers correct-7-horse-3-battery-1-staple-9-foo-2-bar ~94.1 bits
Both Correct-7-Horse-3-battery-1-Staple-9-foo-2-Bar ~100.1 bits

Changes

File What
lib/passphrase.ts Added PassphraseOptions interface, capitalize and includeNumber options, secureRandomBelow() helper, updated passphraseEntropy() to accept options
lib/passphrase.test.ts Expanded from 18 to 42 tests — covers capitalize, includeNumber, combined, entropy calculation with options, edge cases
components/password-input.tsx Added "Capitalize" and "Add numbers" checkboxes in encrypt mode, wired into generatePassphrase()

Test Coverage

  • 47 tests passing (42 passphrase + 5 crypto)
  • passphrase.ts: 100% lines, 100% functions, 95% branches

Closes #14

Add two new options to the passphrase generator for improved password
complexity and security:

- capitalize: randomly capitalizes each word (50% chance per word),
  adding ~1 bit of entropy per word
- includeNumber: inserts a random digit (0-9) between each pair of
  words, adding ~3.32 bits of entropy per digit

The UI exposes these as checkboxes in encrypt mode next to the
generate button. The API is backward compatible — the legacy
positional argument style (wordCount, separator) still works.
Entropy calculation updated to account for the new options.

Closes #14
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
seal3d 9d4b801 Commit Preview URL

Branch Preview URL
Feb 20 2026, 07:16 PM

@valerius21
Copy link
Owner Author

  • wrong generation
  • no checkboxes, enabled by default
  • after generation it should be copied to clipboard. -> extra function using browser api.

@valerius21 valerius21 marked this pull request as draft February 20, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance Password Generation: Add Capitalized Words and Numbers for Security

1 participant