Skip to content

Commit d9f187f

Browse files
committed
Compatibility & minor improvements
- birthdaySeparator fonction improved - Support for null information soon - Graphical improvements
1 parent e08ac61 commit d9f187f

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

passGenerator.py

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import itertools as it
22
import time
33
import os
4-
4+
55
start_time = time.time()
6-
infos = {"Name": "", "Surname": "", "Birthday": ""}
6+
infos = {"Name": "null", "Surname": "null", "Birthday": "null"}
77

88
def saveToTxt(liste: list, filepath: str, filename: str):
99
"""Save a list to a txt file
@@ -28,7 +28,8 @@ def askInfos(liste: dict):
2828
givenInfo = input(f"Enter info : {info} (DD/MM/YYYY)\n")
2929
else:
3030
givenInfo = input(f"Enter info : {info}\n")
31-
liste[info] = givenInfo
31+
if not givenInfo == '':
32+
liste[info] = givenInfo
3233

3334
def allStrings(string: str):
3435
"""Generate a list of upper and lower possibility of a given string
@@ -51,11 +52,12 @@ def birthdaySeparator(birthday: str):
5152
Returns:
5253
(list): day, month and year of birth
5354
"""
54-
birthdayList = list(birthday)
55-
day = birthdayList[0] + birthdayList[1]
56-
month = birthdayList[3] + birthdayList[4]
57-
year = birthdayList[6] + birthdayList[7] + birthdayList[8] + birthdayList[9]
58-
return day, month, year
55+
if len(birthday) == 10:
56+
day = birthday[0:2]
57+
month = birthday[3:5]
58+
year = birthday[6:10]
59+
return day, month, year
60+
return "null"
5961

6062
def passwords(infos: dict):
6163
"""Generate passwords from the given infos
@@ -68,43 +70,46 @@ def passwords(infos: dict):
6870
"""
6971
passwordsList = []
7072
for info in infos:
71-
if not info == "Birthday":
72-
for x in range(len(allStrings(infos[info]))):
73-
passwordsList.append(allStrings(infos[info])[x])
74-
else:
75-
# Name + Surname & Surname + Name
76-
for noms in allStrings(infos["Name"]):
73+
if not infos[info] == "null":
74+
if not info == "Birthday":
75+
for x in range(len(allStrings(infos[info]))):
76+
passwordsList.append(allStrings(infos[info])[x])
77+
else:
78+
# Name + Surname & Surname + Name
79+
for noms in allStrings(infos["Name"]):
80+
for prenom in allStrings(infos["Surname"]):
81+
nomprenom = noms + prenom
82+
prenomnom = prenom + noms
83+
passwordsList.append(prenomnom)
84+
passwordsList.append(nomprenom)
85+
# Name + birthday
86+
for noms in allStrings(infos["Name"]):
87+
noms = noms + birthdaySeparator(infos[info])[2]
88+
passwordsList.append(noms)
89+
# Surname + birthday
7790
for prenom in allStrings(infos["Surname"]):
78-
nomprenom = noms + prenom
79-
prenomnom = prenom + noms
80-
passwordsList.append(prenomnom)
81-
passwordsList.append(nomprenom)
82-
# Name + birthday
83-
for noms in allStrings(infos["Name"]):
84-
noms = noms + birthdaySeparator(infos[info])[2]
85-
passwordsList.append(noms)
86-
# Surname + birthday
87-
for prenom in allStrings(infos["Surname"]):
88-
prenom = prenom + birthdaySeparator(infos[info])[2]
89-
passwordsList.append(prenom)
90-
91+
prenom = prenom + birthdaySeparator(infos[info])[2]
92+
passwordsList.append(prenom)
93+
9194
return passwordsList
92-
93-
askInfos(infos)
95+
9496
print("""
9597
____ ____ ____ ______
9698
/ __ \/ _/ / __ \____ ___________/ ____/__ ____
9799
/ /_/ // /_____/ /_/ / __ `/ ___/ ___/ / __/ _ \/ __ \\
98100
/ ____// /_____/ ____/ /_/ (__ |__ ) /_/ / __/ / / /
99101
/_/ /___/ /_/ \__,_/____/____/\____/\___/_/ /_/
100102
""")
101-
102-
interval = time.time() - start_time
103-
print(f'\nTotal time in seconds: {interval}')
103+
104+
askInfos(infos)
104105

105106
filename = input("Enter name of the output file:\n")
106-
path = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') + "\\passLists\\"
107-
if not os.path.exists(path):
108-
os.makedirs(path)
107+
108+
path = ''
109+
if os.name == "nt":
110+
path = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') + "\\passLists\\"
111+
if not os.path.exists(path):
112+
os.makedirs(path)
109113

110114
saveToTxt(passwords(infos), path, filename)
115+
print(f'\nTotal time: {time.time() - start_time} seconds')

0 commit comments

Comments
 (0)