liveBook · Manning

Password authentication

As explained in Tiny Python Projects: Learn coding and testing with puzzles and games

A password is a secret string of characters used to authenticate a user or protect access to an account or service.

A memorable password can combine four randomly selected words, balancing resistance to guessing with easier recall. A generator can draw from a word list or from cleaned literary text, then combine the selected words into one string. section 20.0

A practical password generator supports these controls:

  • Choose the number of passwords and words per password. section 20.1
  • Filter words by minimum and maximum length, remove non-characters, and title-case the retained words. section 20.1
  • Use a random seed and sorted input so repeated runs produce testable, reproducible selections. section 20.1.6 section 20.3.5
  • Optionally apply leet-style substitutions and append punctuation. section 20.1

Generating reproducible passwords

A command such as `./password.py --num 2 --num_words 3 --seed 9 sonnets/*` produces passwords like `QueenThenceMasked` and `GullDeemdEven`. Increasing the length bounds selects longer words, while `--l33t` produces mixed-case substitutions and punctuation such as `p3RsPeC+1Vesucces5i0niN+3lL1Genc3$`. section 20.1

$ ./password.py -h
usage: password.py [-h] [-n num_passwords] [-w num_words] [-m minimum]
                  [-x maximum] [-s seed] [-l]
                  FILE [FILE ...]

Password maker

positional arguments:
 FILE                  Input file(s)

optional arguments:
 -h, --help            show this help message and exit
 -n num_passwords, --num num_passwords
                       Number of passwords to generate (default: 3)
 -w num_words, --num_words num_words
                       Number of words to use for password (default: 4)
 -m minimum, --min_word_len minimum
                       Minimum word length (default: 3)
 -x maximum, --max_word_len maximum
                       Maximum word length (default: 6)
 -s seed, --seed seed  Random seed (default: None)
 -l, --l33t            Obfuscate letters (default: False)

The command-line help listing makes the generator's files, counts, length filters, seed, and l33t option directly inspectable. section 20.1

How Tiny Python Projects: Learn coding and testing with puzzles and games covers it

How deep it goes
Builds a runnable Python generator with filtering, sampling, reproducibility, transformation, and testing, but defers broader password-storage practices.
Examples
Demonstrates word-list, Constitution, novel, poetry, noun, verb, adjective, seeded, and l33t-generated passwords.
What you can do after
Builds a Python command-line tool that generates configurable, memorable passwords from one or more input files.
How it connects
Connects passwords with entropy, random sampling, command-line arguments, testing, and natural language processing.

Also explained in

Compare how 9 books explain password authentication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny Python Projects: Learn coding and testing with puzzles and games. The section links point to the parts of the book it draws on.