From 8b287689418a54f23b191f304f2f3cb1c5f0fb7b Mon Sep 17 00:00:00 2001 From: AryanMittal11 <164195062+AryanMittal11@users.noreply.github.com> Date: Fri, 22 Mar 2024 21:23:48 +0530 Subject: [PATCH] Add files via upload --- PasswordGenerator.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 PasswordGenerator.py diff --git a/PasswordGenerator.py b/PasswordGenerator.py new file mode 100644 index 0000000..e9d1f49 --- /dev/null +++ b/PasswordGenerator.py @@ -0,0 +1,42 @@ +import random +import string + + +def complex_pass(length): + char1 = string.ascii_letters + string.digits + string.ascii_uppercase + string.ascii_lowercase + string.punctuation + password = ''.join(random.choice(char1) for _ in range(length)) + return password + + +def mod_pass(length): + char1 = string.ascii_letters + string.digits + string.punctuation + password = ''.join(random.choice(char1) for _ in range(length)) + return password + + +def simple_pass(length): + char1 = string.ascii_letters + string.digits + password = ''.join(random.choice(char1) for _ in range(length)) + return password + + +def main(): + while True: + length = int(input("Enter the length of password you want: ")) + if length <= 0: + print("Please enter valid length") + else: + break + complexity = input("Enter the complexity of password (complex/moderate/simple): ") + if complexity == "complex": + print("Your password is : ", complex_pass(length)) + elif complexity == "moderate": + print("Your password is : ", mod_pass(length)) + elif complexity == "simple": + print("Your password is : ", simple_pass(length)) + else: + print("Invalid Option") + + +if __name__ == "__main__": + main()