Skip to content

Commit ec3c16a

Browse files
authored
Add files via upload
1 parent ab1ee16 commit ec3c16a

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Binary file not shown.

PassWord-Generator/alphabet.py

+8
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+

PassWord-Generator/passGenerate.py

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
"""Generate password with Random index and all letters
37+
And Return it in list form"""
38+
sym = alphabet.symbols
39+
a_low = alphabet.a_lower
40+
a_upp = alphabet.a_upper
41+
num = alphabet.numbers
42+
rand_list = [sym, a_low, a_upp, num]
43+
44+
for i in range(lent):
45+
# randomly select a list between four list
46+
temp = random.randint(0,3)
47+
# get length of list
48+
len_target_list = len(rand_list[temp])
49+
select = random.randint(0,len_target_list-1)
50+
ret_value.append(rand_list[temp][select])
51+
return ret_value
52+
53+
54+
def main():
55+
56+
print("passGenerator")
57+
58+
while True:
59+
try:
60+
print('For Quit Enter Q | q')
61+
user = input("\nEnter length on pass you want:\ninput must between 8 to 180\n==> ")
62+
if (user.upper() == 'Q'):
63+
sys.exit(0)
64+
if int(user) < 8 or int(user) >180:
65+
continue
66+
length = int(user)
67+
except (ValueError):
68+
print(f'{Fore.RED}invalid input :(')
69+
pass
70+
except EOFError:
71+
print('Quit Mode !')
72+
sys.exit(0)
73+
else:
74+
break
75+
76+
77+
78+
let = get_letter(length)
79+
random.shuffle(let)
80+
res = validate_pass(let)
81+
if (res == True):
82+
print(f'{Fore.MAGENTA}Password Generate is: ',end='')
83+
for letter in let:
84+
print(f'{Fore.GREEN}{letter}',end='')
85+
print('')
86+
sys.exit(0)
87+
else:
88+
print('We cant Generate a Good password please Enter again :)')
89+
main()
90+
main()

PassWord-Generator/requirement.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Colorama

0 commit comments

Comments
 (0)