DEV Community

loading...

Lockdown Programming Challenges: 2. Password Generator

Daniel Marlow
Updated on ・1 min read

This is the second in the series of lockdown programming challenges I'm going to post over the next few weeks. Remember the aim is to learn something new, try a new programming language, brush up on your clean coding skills or just while away the hours under lockdown. Feel free to post your efforts in the comments.

In the first challenge we looked at password complexity. For this second challenge we're going to create a password generator.

Challenge 2: Create a Password Generator

Create a program that generates a password. Ask the user to enter the following:

  • The minimum total number of characters
  • The minimum number of special characters (&*%&^$ etc)
  • The minimum number of uppercase letters
  • The minimum number of lowercase letters
  • The minimum number of digits

Generate a password that follows these rules specified by the user.

Display your generated password to the user on the screen.

Advanced

Present a number of password possibilities to the user.

Try different mechanisms to randomly generate characters.

Discussion (2)

Collapse
shubh2346 profile image
shubh2346

import random

lower ="abcdefghijklmnopqrstuvwxyz"
upper ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers ="0123456789"
symboles ="[]\•@#$&()"

all=lower+upper+numbers+symboles
length =16
pass ="".join(random.sample(all,length))
print(pass)

Collapse
drm317 profile image
Daniel Marlow Author

Nice