Back to 课程

Computer Science GCES AQA

0% Complete
0/0 Steps
  1. Representing Algorithms Aqa
    4 主题
  2. Efficiency Of Algorithms Aqa
    1 主题
  3. Searching Algorithms Aqa
    3 主题
  4. Sorting Algorithms Aqa
    3 主题
  5. Data Types Aqa
    1 主题
  6. Programming Concepts Aqa
    5 主题
  7. Arithmetic Relational And Boolean Operations Aqa
    1 主题
  8. Data Structures Aqa
    3 主题
  9. String Manipulation Aqa
    1 主题
  10. Random Number Generation Aqa
    1 主题
  11. Structured Programming Aqa
    2 主题
  12. Robust And Secure Programming Aqa
    4 主题
  13. Number Bases Aqa
    2 主题
  14. Converting Between Number Bases Aqa
    3 主题
  15. Units Of Information Aqa
    9 主题
  16. Hardware And Software Aqa
    4 主题
  17. Boolean Logic Aqa
    3 主题
  18. Programming Languages And Translators Aqa
    2 主题
  19. Cpu Architecture Performance And Embedded Systems Aqa
    4 主题
  20. Memory Aqa
    2 主题
  21. Secondary Storage Aqa
    3 主题
  22. Fundamentals Of Computer Networks Aqa
    8 主题
  23. Fundamentals Of Cyber Security Aqa
    1 主题
  24. Methods Of Preventing Cyber Security Threats Aqa
    1 主题
  25. Relational Databases Aqa
    2 主题
  26. Ethical Legal And Environmental Impacts Aqa
    2 主题
课 Progress
0% Complete

Exam code:8525

Authentication Routines

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 is include

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

    • Encrypting data

authentication-recaptcha

Writing authentication routines

  • An authentication routine is a method a programmer can use to ensure a user is entering the correct credentials to access a program or system

  • The exam requirements are that students only need to be able to write plain text authentication routines and do not need to include encryption 

  • The examples below will be written in Python

Example authentication code using an If statement

  • This first program is a very simple version and would not be used in a real-world program

  • This example demonstrates the fundamentals of how an authentication check would take place

username = input("Enter a username ")
password = input("Enter a password ")
if username == "SaveMyExams" and password == "coding":
print("Welcome to the program"
else:
print("Wrong details entered")

Example authentication code using a 2D array

  • This second program is a better version which stores the usernames and passwords in a 2 dimensional array

  • This example demonstrates how iteration and selection can be used together to store and retrieve information

#2d array containing the usernames and passwords
users = [

["Dave", "password"],

["Alice", "password2"],

["Bob", "password3"],

["Jane", "password4"]

]

#Asks for the user to input their username

username = input("Enter username: ")

#Loops through the array to find the username input by the user
for i in range (0,len(users)):

if users[i][0] == username:
#If the username is found, it will ask for their password

password = input("Enter password: ")

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

print("Welcome back " + username)

else:

print("Wrong password " + username)

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注