Project 1 of 20, for Caitlin
Password Generator
Passwords and passphrases for the Studio's Friday-night game server: sensible defaults, options by name, and nothing anyone can guess.
Sign up free to open itLog in
Act 2 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- CaitlinWe're getting a game server in the Studio for Friday nights, and everyone in the class is going to need a password.
- CaitlinI made six up myself and Yahya guessed four of them before the kettle had even boiled.
- CaitlinThe other two were highscore1 and highscore2, which he got straight after.
- PaulLet's get a program to make them instead, with sensible defaults and a few options for anyone who's fussy.
Write passwords.py, with a docstring in every function.
make_password(length=12, digits=True, symbols=False, avoid_lookalikes=True)returns a password oflengthcharacters. It always uses lower case and capital letters; digits ifdigitsis true; and the characters inSYMBOLSifsymbolsis true. It has at least one character of every kind it uses. Withavoid_lookalikes, it never uses any ofLOOKALIKES(Il1O0o).make_passphrase(words=4, sep="-", capitalise=False)returns that many words from the word list, joined bysep. Withcapitalise, each word starts with a capital.make_passwords(*names, issued=None, **options)makes a password for each name withmake_password(**options)and returns a dictionary of name to password. Given anissueddictionary, it adds to that one and returns it; without one, it starts a new dictionary every time.
Anything a password is made from comes from secrets, never random.
Passwords for the game server: Aaesha: tK7fWq2mRbXe Caitlin: Hn3zVp8sCwYd Yahya: qD4hTx9jMkPa Passphrase for the Wi-Fi: ample-crust-vowel-tidal
What you learn
What's in it
- Characters nobody can guess
- Characters to choose from
- A value to fall back on
- Something to fall back on
- Arguments by name
- By name
- Saying what it does
- Which string
- Any number of names
- The size goes where
- Any number of options
- Any number of classmates
- A default made once
- The default that remembers
- The same numbers every run
- The same every time
- How Paul would do it
- Fix Yahya's version
- Make the password generator
- Ship it