Most of the current rules for how to set passwords are counter-productive, as nicely illustrated by Randall Monroe's xkcd comic:
As he points out, a better method is to pick several unrelated words and combine them.
This site has a large list of words that you can use to generate a good password:
https://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain (Links to an external site.)
Copy the words from that site into a text file (one word per line is easiest).
Write a python program that imports those words from your text file into a tuple, list or array. Then write a function that will generate a password from <n> (this should be an input to the function) random words chosen from the data structure. Each random word should be capitalized. You can use a built-in function to capitalize each word, or write your own!
Sample results might look like:
request 4 words - TreatmentCatUncleParty
request 3 words - PipeBoundarySkin
Your main program should ask for a security "level" from 1 (casual) - 5 (top secret). Then it should use your function to generate a password based on the security level with "level + 2" random words. Attach your text file of words to the assignment as well (.txt, .dat and .csv extensions are all allowed)
Python Program:
import random
def capitilizingWords(lines, n):
randomWords = random.sample(lines, n) # Randomly choose n number of words from list
capitalWords = [word.title() for word in randomWords] # Capitilizing each words in randomly choosen list
print("Requested {0} words - ".format(n), "".join(capitalWords)) # Printing output
# Main Driver Function
if __name__ == '__main__':
# Add all texts in file into list
lines = []
with open("input.txt") as f:
for line in f:
lines.append(line.strip())
n = int(input("Enter Number Of Words: ")) # Input how many words you want
capitilizingWords(lines, n) # Function to Capitilizing words
Output 1:
Output 2:
Thumbs Up Please !!!
Get Answers For Free
Most questions answered within 1 hours.