From 16e3a913c93a0c2e6797ba493932070560e53a74 Mon Sep 17 00:00:00 2001 From: Carlos Ramos Date: Tue, 23 Jun 2020 01:42:22 -0500 Subject: [PATCH] =?UTF-8?q?creador=20de=20contrase=C3=B1as=20seguras=20ret?= =?UTF-8?q?o=20resuelto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index fc9a525..13520e0 100644 --- a/src/main.py +++ b/src/main.py @@ -1,11 +1,40 @@ # Resolve the problem!! import string +import random SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~') +UPPERCASE = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') +LOWERCASE = list('abcdefghijklmnopqrstuvwxyz') +NUMBER = list('0123456789') + def generate_password(): - # Start coding here + + password = [] + length = random.randrange(8,17) + random.shuffle(NUMBER) + random.shuffle(SYMBOLS) + random.shuffle(UPPERCASE) + random.shuffle(LOWERCASE) + password.append(random.choice(UPPERCASE)) + password.append(random.choice(LOWERCASE)) + password.append(random.choice(NUMBER)) + password.append(random.choice(SYMBOLS)) + length = length - 4 + while length > 0: + choiceList = random.randrange(1,5) + if choiceList == 1: + password.append(random.choice(UPPERCASE)) + elif choiceList == 2: + password.append(random.choice(LOWERCASE)) + elif choiceList == 3: + password.append(random.choice(NUMBER)) + elif choiceList == 4: + password.append(random.choice(SYMBOLS)) + length -= 1 + strpassword = "".join(password) + return password def validate(password):