Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
# Resolve the problem!!
import string
import random

SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~')

UPPERCASES = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
LOWERCASES = list('abcdefghijklmnopqrstuvwxyz')
DIGITS = list('0123456789')

def generate_password():
# Start coding here
"""
1. Create a list with a random lenght between 8 and 16, filled with x
2. Fill the list with every type of characters radomly, diff. even and odd
3. Because the list was filled with an even-odd index order, it must be shuffle randomly
"""

length = random.randint(8, 16)
password = list('x' * length)

i = 0
while i < length/2:
if i%2 == 0:
password[i] = SYMBOLS[random.randint(0, len(SYMBOLS)-1)]
i += 1
else:
password[i] = DIGITS[random.randint(0, len(DIGITS)-1)]
i += 1

while i < length:
if i%2 == 0:
password[i] = UPPERCASES[random.randint(0, len(UPPERCASES)-1)]
i += 1
else:
password[i] = LOWERCASES[random.randint(0, len(LOWERCASES)-1)]
i += 1

random.shuffle(password)
str_pass = ''

return str_pass.join(password)


def validate(password):
Expand Down