Programming Authentication (Edexcel GCSE Computer Science)

Revision Note

James Woodhouse

Written by: James Woodhouse

Reviewed by: Lucy Kirkham

Programming Authentication

What is Authentication?

  • Authentication is the process of ensuring that a system is secure by asking the user to complete tasks to prove they are an authorised user of the system

  • Authentication is done because bots can submit data in online forms

  • Authentication can be done in several ways, these include

    • Usernames and Passwords

    • CAPTCHA

  • Other methods that programmers can do to authenticate the user include

    • Allowing users to recover passwords via email links and SMS codes

    • Encrypting data

authentication-recaptcha

How can authentication be programmed?

  • Authentication of usernames and passwords can be programmed in several ways, including using lists, databases and encryption

  • Students are required to be able to program looking up usernames and passwords using a list/array

  • To do this successfully, a 2-dimensional list/array will be used

Python example

# Set a Boolean flag to track if the username is found

found = False

# List of usernames and corresponding passwords

usernames = [

["Dave", "1"],

["Steve", "2"],

["James", "3"],

["Alice", "4"],

["Stephanie", "5"]

]

# Ask the user to input their username

user = input("Enter your username: ")

# Loop through each username in the list

for i in range(len(usernames)):

# Check if the entered username matches any in the list

if user == usernames[i][0]:

found = True # Set the flag to indicate the username is found

password = input("Enter your password: ") # Ask for the password

# Check if the entered password matches the password associated with the username

if password == usernames[i][1]:

print("Welcome")

else:

print("Wrong password")

# Check if the username was not found

if not found:

print("User not found")

Last updated:

You've read 0 of your 5 free revision notes this week

Sign up now. It’s free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.