Created
December 6, 2018 11:14
-
-
Save Harrisoon/ebc9530d014cd36acdb4042dae4b980a to your computer and use it in GitHub Desktop.
Password Creator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import secrets as s | |
""" | |
This program generates a password of length n. | |
Programma also generates a code name of length n. | |
Requires the dictionary.txt and the nouns and adjective files to run | |
""" | |
class Generator: | |
def __init__(self, pw_number_of_words=5): | |
self.pw_number_of_words = pw_number_of_words | |
def Word_Password(self): | |
""" | |
Retrieves the words from the dictionary. | |
Generates a password of n number of words, seperated by a grammatical character, randomly assigns some as capital. | |
@param pw_number_of_words: Desired length of password. Default 5 words. | |
""" | |
pswd = "" | |
text_file = open("Dictionary/dictionary.txt").readlines() | |
text_length = len(text_file) | |
counter = 0 | |
while counter < self.pw_number_of_words: | |
wrd = text_file[s.randbelow(text_length)][:-1] | |
r = s.randbelow(4)+1 | |
if 4 % r: | |
wrd = wrd.upper() | |
if r == 1: | |
space = "-" | |
grammer = "!" | |
elif r == 2: | |
space = "_" | |
grammer = "?" | |
elif r == 3: | |
space = " " | |
grammer = "/" | |
else: | |
space = "~" | |
grammer = "|" | |
pswd += (wrd+space) | |
counter+=1 | |
for x in range(0, 2): | |
pswd += str(s.randbelow(8)+1) | |
for x in range(0, 2): | |
pswd += grammer | |
return pswd | |
# for x in range(0, 10): | |
# print(Generator().Word_Password()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment