20 Password strength: Generating a secure and memorable password

It’s not easy to create passwords that are both difficult to guess and easy to remember. An XKCD comic describes an algorithm that provides both security and recall by suggesting that a password be composed of “four random common words” (https://xkcd.com/936/). For instance, the comic suggests that the password composed of the words “correct,” “horse,” “battery,” and “staple” would provide “~44 bits of entropy” which would require around 550 years for a computer to guess, given 1,000 guesses per second.

We’re going to write a program called password.py that will create passwords by randomly combining words from some input files. Many computers have a file that lists thousands ...

Get Tiny Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.