Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions password-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import random

char = [[], [], [], []]
char[0] = ["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"]
char[1] = ["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"]
char[2] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
char[3] = ["-", "_", "+", "#", "*", "~"]
password = ""

passwordLength = 0

def passLength():
global passwordLength
passwordLength = int(input("Length of generated password (8-20): "))
if (not (passwordLength >= 8 and passwordLength <= 20)):
print("The given length for a password is not allowed.")
passLength()


passLength()

for i in range(passwordLength):
randInt = random.randint(0,3)
password += str(random.choice(char[randInt]))

print("Your generated password with " + str(passwordLength) + " digits is: " + password)