Passwords
Introductory tasks
Students could be asked what makes a good password, what general rules are there for passwords and the advantages and disadvantages of biometric passwords compared to ones you have to type in.
The problem
A password has been set to fish fingers. Students must write a program to set their own password. It must be identically entered in twice before it is accepted. Then, students must simulate logging in by entering in their password to continue. They can only have three attempts at entering in the correct password. If they enter in the correct password, the program finishes with a 'congratulations' message. If they cannot log-in, a message to contact the Network Manager must be displayed.
Overview of our solution
set the password to 'fish fingers'
function to ask the user to change their password
function to log-in
call functions
Pseudo-code
set password1 = fish
set password2 = fingers
def set_password():
global password1, password2
while password1 doesn't equal password2
enter password1
enter password2
password1 != password2
def login():
global password1, password2
set counter = 1
enter password
while guess != password and counter < 3
enter password
counter += 1
if guess = password:
print ('Logged in!')
elif counter >= 3:
print ('Contact Network Manager')
set_password()
login()
Solution
Extension
Students can modify this program in a number of ways. They could give the user an option for answering a security question to get back a password. They could use a dictionary to set up user login names against passwords and then allow different users to be verified.