From 93a053cac10c9ea297448a951ef28dce23e6fdc3 Mon Sep 17 00:00:00 2001 From: "vh_cm_@hotmail.com" Date: Tue, 11 Aug 2020 02:58:52 -0500 Subject: [PATCH] Prueba 2 python --- Challenge_2.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Challenge_2.py diff --git a/Challenge_2.py b/Challenge_2.py new file mode 100644 index 0000000..63e6b1c --- /dev/null +++ b/Challenge_2.py @@ -0,0 +1,70 @@ + +# Resolve the problem!! +import string +import random + +SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~') + + +def generate_password(): + password = '' + chars = random.randint(8,16) + for x in range(chars): + + digita = random.randint(48,57) + upper = random.randint(65, 90) + lower = random.randint(97, 122) + simbolos = random.choice(SYMBOLS) + mini = [chr(digita), chr(upper), chr(lower), simbolos] + password += random.choice(mini) + return password + + #return(password) + + + + +def validate(password): + + if len(password) >= 8 and len(password) <= 16: + has_lowercase_letters = False + has_numbers = False + has_uppercase_letters = False + has_symbols = False + + for char in password: + if char in string.ascii_lowercase: + has_lowercase_letters = True + break + + for char in password: + if char in string.ascii_uppercase: + has_uppercase_letters = True + break + + for char in password: + if char in string.digits: + has_numbers = True + break + + for char in password: + if char in SYMBOLS: + has_symbols = True + break + + if has_symbols and has_numbers and has_lowercase_letters and has_uppercase_letters: + return True + return False + + +def run(): + password = generate_password() + print(password) + if validate(password): + print('Secure Password') + else: + print('Insecure Password') + + +if __name__ == '__main__': + run() \ No newline at end of file