Skip to main content

A Python library to generate secure, meaningful passphrases.

Project description

BetterPassphrase

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


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.

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.generator 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 --verbose

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 (true/false) False
--output -o Save passphrase to a file None
--verbose -v Print verbose information (true/false) False

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: TheActorAndTheSubtleDancerPlayedWonderfully
Word count:       8

To write the passphrase to a file:

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

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

Verbose mode can provide additional details:

$ betterpassphrase --length 6 --verbose
Generated phrase: the-actor-and-the-subtle-dancer-played-wonderfully
Word count:       8
Probability:      3.733316339298084e-18
Parts of speech:  DETERMINER, SUBJECT_NOUN, CONJUNCTION, DETERMINER, ADJECTIVE, OBJECT_NOUN, VERB, ADVERB

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

betterpassphrase-0.1.5.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BetterPassphrase-0.1.5-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file betterpassphrase-0.1.5.tar.gz.

File metadata

  • Download URL: betterpassphrase-0.1.5.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for betterpassphrase-0.1.5.tar.gz
Algorithm Hash digest
SHA256 59672b660d0686a5515f899163d83352abb058c4d37959f2862895ba8344109f
MD5 3a54d8330cde7878cecbcd687ecaeb75
BLAKE2b-256 600b982f8e1554cca00f7523aa25f66b36ba6a7d95cfe1bc765a61ccad63576d

See more details on using hashes here.

File details

Details for the file BetterPassphrase-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for BetterPassphrase-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c957023030a769a01021c4232beebd892d89341649a85f569172f76390f19c49
MD5 5369aa27dbc2bd4e40aac28c6e8f0c8e
BLAKE2b-256 8ed3ace3ab02d714415a3627e30bf0f61acfee66447e1848d5a991fdcf3c3c7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page