Skip to content

Commit 5e5a564

Browse files
authored
add file
1 parent 5582ed4 commit 5e5a564

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
438 Bytes
Binary file not shown.

passGenerator/alphabet.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# All alphabet and symboles
2+
3+
a_upper = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
4+
a_lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
5+
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
6+
symbols = ['!', '#', '$', '%', '&', '*', '+', '-' , '?','/',]
7+
8+

passGenerator/passGenerate.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import random
2+
import sys
3+
import alphabet
4+
from colorama import Fore,init
5+
6+
init()
7+
8+
def validate_pass(passwd):
9+
"""after password generate it this function analyze generate password
10+
if password is not required rule program regenerate password again"""
11+
# rule :
12+
# password should have at least One Upper One lower One number
13+
# and One symbol
14+
upper = 0
15+
lower = 0
16+
numb = 0
17+
sym = 0
18+
for i in passwd:
19+
if i.isnumeric():
20+
numb += 1
21+
elif i.isupper():
22+
upper += 1
23+
elif i.isupper():
24+
lower += 1
25+
elif ord(i) >= 48 and ord(i) <= 58:
26+
sym +=1
27+
28+
if not upper or not sym or not upper or not lower or not numb:
29+
return True
30+
return False
31+
32+
33+
34+
def get_letter(lent):
35+
ret_value = []
36+
37+
sym = alphabet.symbols
38+
a_low = alphabet.a_lower
39+
a_upp = alphabet.a_upper
40+
num = alphabet.numbers
41+
rand_list = [sym, a_low, a_upp, num]
42+
43+
for i in range(lent):
44+
# randomly select a list between four list
45+
temp = random.randint(0,3)
46+
# get length of list
47+
len_target_list = len(rand_list[temp])
48+
select = random.randint(0,len_target_list-1)
49+
ret_value.append(rand_list[temp][select])
50+
return ret_value
51+
52+
53+
def main():
54+
print("passGenerator")
55+
56+
while True:
57+
try:
58+
print('For Quit Enter Q | q')
59+
user = input("\nEnter length on pass you want:\ninput must between 8 to 180\n==> ")
60+
if (user.upper() == 'Q'):
61+
sys.exit(0)
62+
if int(user) < 6 or int(user) >180:
63+
continue
64+
length = int(user)
65+
except (ValueError):
66+
print(f'{Fore.RED}invalid input :(')
67+
pass
68+
except EOFError:
69+
print('Quit Mode !')
70+
sys.exit(0)
71+
else:
72+
break
73+
74+
75+
76+
let = get_letter(length)
77+
random.shuffle(let)
78+
res = validate_pass(let)
79+
if (res == True):
80+
print(f'{Fore.MAGENTA}Password Generate is: ',end='')
81+
for letter in let:
82+
print(f'{Fore.GREEN}{letter}',end='')
83+
print('')
84+
sys.exit(0)
85+
else:
86+
print('We cant Generate a Good password please Enter again :)')
87+
main()
88+
main()

0 commit comments

Comments
 (0)