commit 3b29657c5fc4dffffe07eac573993cef8f664b42 Author: Philipp Date: Tue Apr 21 16:36:18 2026 +0200 password-generator 1.0 diff --git a/every.py b/every.py new file mode 100644 index 0000000..282d930 --- /dev/null +++ b/every.py @@ -0,0 +1,36 @@ + +#libraries + +import secrets +import string + +#create password + +def create_password(length: int) -> str: + pool = string.ascii_letters + string.digits + string.punctuation + + while True: + + password = ''.join(secrets.choice(pool) for _ in range(length)) + + if any(char.isdigit() for char in password): + return password +#length and check +while True: + + try: + length = int(input("Choice the length of the password: ")) + + if length >= 4: + break + + else: + print("the number must be 4 or bigger") + + except ValueError: + print("only numbers are allowed") + + +#output +print("password: ", create_password(length)) + diff --git a/main.py b/main.py new file mode 100644 index 0000000..6d969df --- /dev/null +++ b/main.py @@ -0,0 +1,37 @@ +#imports + +import subprocess + +#selection +while True: + print("choice password-layout") + print("[1] every ascii-characters") + print("[2] only numbers") + print("[3] just with normol special characters") + print("[4] quit") + +#dict and variable + + files = { + 1: "every.py", + 2: "numbers.py", + 3: "onlynormal.py", + } + + try: + choiced = int(input()) + + if choiced == 4: + break + + if choiced in files: + filename = files[choiced] + subprocess.run(["python3", filename]) + + else: + print("Not in the list") + + except ValueError: + print("choice one of the numbers above") + + diff --git a/numbers.py b/numbers.py new file mode 100644 index 0000000..e77dc29 --- /dev/null +++ b/numbers.py @@ -0,0 +1,28 @@ +#imports + +import string +import secrets + +#create password + +def create_password(length: int) -> str: + pool = string.digits + return ''.join(secrets.choice(pool) for _ in range(length)) + +#length and check +while True: + + try: + length = int(input("Choice the length of the password: ")) + + if length >= 4: + break + + else: + print("the number must be 4 or biggger") + + except ValueError: + print("only numbers are allowed") + +#output +print("password: ", create_password(length)) diff --git a/onlynormal.py b/onlynormal.py new file mode 100644 index 0000000..2138fdc --- /dev/null +++ b/onlynormal.py @@ -0,0 +1,34 @@ +#imports + +import string +import secrets + +#create password + +def create_password(length: int) -> str: + pool = string.ascii_letters + string. digits + pool += "!?.,-_/;:@" + + while True: + + password = ''.join(secrets.choice(pool) for _ in range(length)) + + if any(char.isdigit() for char in password): + return password +#length and chek +while True: + try: + length = int(input("Choice the length of the password: ")) + + if length >= 4: + break + + else: + print("the number must be 4 or more") + + except ValueError: + print("only numbers are allowed") + +#output + +print("password: ", create_password(length))