Skip to main content

BetterPassphrase

BetterPassphrase is a Python library and CLI tool for generating somewhat secure, meaningful passphrases. It uses various parts of speech to construct grammatically correct and easy-to-remember phrases.

PyPI version Python 3.10+ License: MIT Downloads


Features

  • Customizable Length: Generate passphrases with a specified number of words.
  • Custom Separators: Use any character as a separator between words.
  • Capitalization Options: Choose whether to capitalize the words in the passphrase.
  • Probability Calculation: Get the uniqueness probability of the generated passphrase.
  • Verbose Output: Optionally display detailed information about the generation process.
  • CLI Support: Generate passphrases directly from the command line.
  • Multiple Phrases: Generate multiple passphrases at once.
  • Output to File: Save generated passphrases to a file.

Installation

Install the package via PyPI:

pip install BetterPassphrase

Usage

Library Usage

Use the library in your Python code to generate passphrases programmatically:

from betterpassphrase import generate_phrase

# Generate a passphrase
phrase = generate_phrase(length=6, sep="-", capitalize=True)

print(f"Generated passphrase: {phrase.passphrase}")
print(f"Word count: {phrase.word_count}")
print(f"Probability: {1 / phrase.one_of:.2e}")

CLI Usage

After installing the package, you can use the betterpassphrase command directly from your terminal:

betterpassphrase --length 6 --sep "" --capitalize --verbosity 1

Options

Option Short Flag Description Default
--length -l Number of words in the passphrase 6
--sep -s Separator to use between words -
--capitalize -c Capitalize the words False
--output -o Save passphrase to a file None
--num-phrases -n Number of passphrases to generate 1
--verbosity -v Verbosity level: 0 (passphrase only), 1 (basic), 2 (detailed) 0

Example CLI Output

$ betterpassphrase --length 8 --sep "-"
Generated phrase: the-actor-and-the-subtle-dancer-played-wonderfully
Word count:       8

To generate a passphrase with capitalization and a custom separator:

$ betterpassphrase --length 8 --sep "=" --capitalize
Generated phrase: The=Actor=And=The=Subtle=Dancer=Played=Wonderfully
Word count:       8

To generate multiple passphrases:

$ betterpassphrase --length 4 --num-phrases 3
Generated phrase: curious-monkey-jumped-over
Generated phrase: silent-shadow-walked-alone
Generated phrase: sloppy-photographer-developed-timer

To write the passphrase(s) to a file:

$ betterpassphrase --length 8 --sep "-" --output passphrase.txt
Generated phrase: the-actor-and-the-subtle-dancer-played-wonderfully

$ cat passphrase.txt
the-actor-and-the-subtle-dancer-played-wonderfully

Verbose mode can provide additional details:

$ betterpassphrase --length 6 --verbosity 2
Generated phrase:       what-dirty-photographer-wrapped-which-stethoscope
Word count:             6
Wordlist Probability:   3.64e-14
Character Probability:  5.51e-63
Parts of speech:        determiner, adjective, subject_noun, verb, determiner, object_noun

Development

Setting Up for Local Development

  1. Clone the repository:

    git clone https://github.com/yourusername/BetterPassphrase.git
    cd BetterPassphrase
    
  2. Install the package locally in editable mode:

    pip install -e .
    
  3. Run tests:

    pytest
    

Contributing

Contributions are welcome! If you have ideas for improvements or new features, feel free to open an issue or submit a pull request.

  1. Fork the repository.
  2. Create a feature branch.
  3. Commit your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

Subhayu Kumar Bala


Acknowledgments

  • Inspired by the concept of secure passphrases for authentication.
  • Built with Python's secrets and random libraries for randomness and security.

Metadata

Release files for BetterPassphrase 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BetterPassphrase 0.1.8
File Size Uploaded
betterpassphrase-0.1.8.tar.gz 19.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BetterPassphrase 0.1.8
File Interpreter ABI Platform
betterpassphrase-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 40.9 kB

Release files / betterpassphrase-0.1.8.tar.gz

Download URL betterpassphrase-0.1.8.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e1bf1743d5e33c09ff68584e1220f9bf97d49b3e6566f50de85a870941d0543d
BLAKE2b-256 checksum
How to use checksums
cad24e9d00f5efb247dc3d5b91810961ba54463b8d5e2586730000d849cdeda4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / betterpassphrase-0.1.8-py3-none-any.whl

Download URL betterpassphrase-0.1.8-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82f25a037c68291020d27ee57201059609a7040a2fc4c536396fa1262a0bbf04
BLAKE2b-256 checksum
How to use checksums
facfa2a9ebe322cb62b7f8b1bc2d51beb473cb90a983b8d104a000c4e0ffb68a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page