59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
import random
|
|
from dictionaries import *
|
|
|
|
options = {
|
|
"minimum_length": 18,
|
|
"capitalize_first_letter": True,
|
|
"leet_it": True,
|
|
"add_number_to_end": False,
|
|
"add_special_to_end": False,
|
|
}
|
|
|
|
def leetspeak_substitutions(string, num_substitutions):
|
|
for i in range(num_substitutions):
|
|
while True:
|
|
index = random.randint(0, len(string)-1)
|
|
letter = string[index]
|
|
|
|
if letter.lower() in leetspeak:
|
|
string = string[:index] + leetspeak[letter.lower()] + string[index + 1:]
|
|
break
|
|
return string
|
|
|
|
def add_random_number(string):
|
|
rand_num = random.randint(0, 9)
|
|
return string + str(rand_num)
|
|
|
|
def add_random_special_char(string):
|
|
special_chars = ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+"]
|
|
rand_index = random.randint(0, len(special_chars) - 1)
|
|
return string + special_chars[rand_index]
|
|
|
|
password = ""
|
|
|
|
# ENTRY
|
|
with open("diceware.txt") as f:
|
|
diceware = [x[:-1] for x in f.readlines()]
|
|
|
|
while len(password) <= options["minimum_length"]:
|
|
index = random.randint(0, len(diceware))
|
|
chosen_word = diceware[index]
|
|
if(options["capitalize_first_letter"] == True):
|
|
chosen_word = chosen_word.capitalize()
|
|
password += chosen_word
|
|
|
|
print("Standard Password:\t" + password)
|
|
|
|
if options["leet_it"]:
|
|
password = leetspeak_substitutions(password, 3)
|
|
|
|
if options["add_number_to_end"]:
|
|
password = add_random_number(password)
|
|
|
|
if options["add_special_to_end"]:
|
|
password = add_random_special_char(password)
|
|
|
|
# Print the generated password
|
|
print("Funky Password: \t"+password)
|
|
|