From b39dcd7e4292535be1e011e62f01c85914c824f5 Mon Sep 17 00:00:00 2001 From: heinertill <94447935+heinertill@users.noreply.github.com> Date: Tue, 30 Nov 2021 22:20:24 +0100 Subject: [PATCH] Created Python file password-generator Added a simple generator for passwords using python. User can choose a length between 8 and 20 and gets a random generated password with uppercase letters, lowercase letters, numbers and special characters. File creation was regarding Issue #04 of "Yamini-8750" --- password-generator.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 password-generator.py diff --git a/password-generator.py b/password-generator.py new file mode 100644 index 0000000..fb458a4 --- /dev/null +++ b/password-generator.py @@ -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)