A Python library to generate secure, meaningful passphrases.
Project description
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.
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
-
Clone the repository:
git clone https://github.com/yourusername/BetterPassphrase.git cd BetterPassphrase
-
Install the package locally in editable mode:
pip install -e .
-
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.
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Acknowledgments
- Inspired by the concept of secure passphrases for authentication.
- Built with Python's
secretsandrandomlibraries 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file betterpassphrase-0.1.7.tar.gz.
File metadata
- Download URL: betterpassphrase-0.1.7.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b03358b030e00900455f62184101268cf5f4158d925c7d0555795c7c1ef4bad
|
|
| MD5 |
760587320707740fcc3780c7d315d0bc
|
|
| BLAKE2b-256 |
72bae4c621ff0d13b2d2a7b8912f6aa5fe75b6285b34e16d60ccbae02f641fbb
|
File details
Details for the file BetterPassphrase-0.1.7-py3-none-any.whl.
File metadata
- Download URL: BetterPassphrase-0.1.7-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65763c00ac599a12e3bdefeeaa80450d4e6ecb61725a84de1ec0cbfee55c745
|
|
| MD5 |
b388297e9ed98a3d954e6ea66a3f0935
|
|
| BLAKE2b-256 |
34d7fe35801494550cc8e87d1b11313260a919df412c713927d20bad33082788
|