1
1
import itertools as it
2
2
import time
3
3
import os
4
-
4
+
5
5
start_time = time .time ()
6
- infos = {"Name" : "" , "Surname" : "" , "Birthday" : "" }
6
+ infos = {"Name" : "null " , "Surname" : "null " , "Birthday" : "null " }
7
7
8
8
def saveToTxt (liste : list , filepath : str , filename : str ):
9
9
"""Save a list to a txt file
@@ -28,7 +28,8 @@ def askInfos(liste: dict):
28
28
givenInfo = input (f"Enter info : { info } (DD/MM/YYYY)\n " )
29
29
else :
30
30
givenInfo = input (f"Enter info : { info } \n " )
31
- liste [info ] = givenInfo
31
+ if not givenInfo == '' :
32
+ liste [info ] = givenInfo
32
33
33
34
def allStrings (string : str ):
34
35
"""Generate a list of upper and lower possibility of a given string
@@ -51,11 +52,12 @@ def birthdaySeparator(birthday: str):
51
52
Returns:
52
53
(list): day, month and year of birth
53
54
"""
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"
59
61
60
62
def passwords (infos : dict ):
61
63
"""Generate passwords from the given infos
@@ -68,43 +70,46 @@ def passwords(infos: dict):
68
70
"""
69
71
passwordsList = []
70
72
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
77
90
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
+
91
94
return passwordsList
92
-
93
- askInfos (infos )
95
+
94
96
print ("""
95
97
____ ____ ____ ______
96
98
/ __ \/ _/ / __ \____ ___________/ ____/__ ____
97
99
/ /_/ // /_____/ /_/ / __ `/ ___/ ___/ / __/ _ \/ __ \\
98
100
/ ____// /_____/ ____/ /_/ (__ |__ ) /_/ / __/ / / /
99
101
/_/ /___/ /_/ \__,_/____/____/\____/\___/_/ /_/
100
102
""" )
101
-
102
- interval = time .time () - start_time
103
- print (f'\n Total time in seconds: { interval } ' )
103
+
104
+ askInfos (infos )
104
105
105
106
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 )
109
113
110
114
saveToTxt (passwords (infos ), path , filename )
115
+ print (f'\n Total time: { time .time () - start_time } seconds' )
0 commit comments