Skip to content

Commit 2eff113

Browse files
committed
Create main.py
-basic version of the password generator -can generate the following types: --only characters (e.g. "EfhweHEFsaH") --characters and numbers (e.g. "A73jI39hP") --characters, numbers and special characters (e.g. "U!48jl.(jd")
0 parents  commit 2eff113

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

main.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import random
2+
def Password_Generator(length,type):
3+
password = ""
4+
if type == "char":
5+
possible_characters = ["A","a","B","b","C","c","D","d","E","e","F","f","G","g","H","h","I","i","J","j","K","k","L","l","M","m","N","n","O","o","P","p","Q","q","R","r","S","s","T","t","U","u","V","v","W","w","X","x","Y","y","Z","z"]
6+
length_possible_characters = len(possible_characters)
7+
for pos in range(length):
8+
rand_int = random.randint(0,length_possible_characters-1)
9+
password = password+possible_characters[rand_int]
10+
return password
11+
if type == "char_num":
12+
possible_characters = ["1","2","3","4","5","6","7","8","9","0","A", "a", "B", "b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h", "I", "i",
13+
"J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r",
14+
"S", "s", "T", "t", "U", "u", "V", "v", "W", "w", "X", "x", "Y", "y", "Z", "z"]
15+
length_possible_characters = len(possible_characters)
16+
for pos in range(length):
17+
rand_int = random.randint(0, length_possible_characters - 1)
18+
password = password + possible_characters[rand_int]
19+
return password
20+
if type == "char_num_special-char":
21+
possible_characters = ["+","*","%","&","/","(",")","=","?","^","!","$"",",".","-",";",":","_","1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "a", "B", "b", "C", "c", "D", "d",
22+
"E", "e", "F", "f", "G", "g", "H", "h", "I", "i",
23+
"J", "j", "K", "k", "L", "l", "M", "m", "N", "n", "O", "o", "P", "p", "Q", "q", "R", "r",
24+
"S", "s", "T", "t", "U", "u", "V", "v", "W", "w", "X", "x", "Y", "y", "Z", "z"]
25+
length_possible_characters = len(possible_characters)
26+
for pos in range(length):
27+
rand_int = random.randint(0, length_possible_characters - 1)
28+
password = password + possible_characters[rand_int]
29+
return password
30+
def configure():
31+
# the length defines, how long the password will be
32+
length = 16
33+
# type defines, what types of character is the password made of:
34+
# "char" = only characters (e.g. "EfhweHEFsaH")
35+
# "char_num" = characters and numbers (e.g. "A73jI39hP")
36+
# "char_num_special-char" = characters, numbers and special characters (e.g. "U!48jl.(jd")
37+
# the special characters are: +*%&/()=?^!$,.-;:_
38+
type = "char_num_special-char"
39+
print("length of password:")
40+
print(length)
41+
print("type of password:")
42+
print(type)
43+
print("Generated password:")
44+
print(Password_Generator(length,type))
45+
46+
if __name__ == '__main__':
47+
configure()

0 commit comments

Comments
 (0)