Back to 课程

Computer Science GCES EDEXCEL

0% Complete
0/0 Steps
  1. Decomposition And Abstraction Edexcel
    2 主题
  2. Algorithms Edexcel
    11 主题
  3. Truth Tables Edexcel
    3 主题
  4. Binary Edexcel
    6 主题
  5. Data Representation Edexcel
    4 主题
  6. Data Storage And Compression Edexcel
    2 主题
  7. Hardware Edexcel
    5 主题
  8. Software Edexcel
    3 主题
  9. Programming Languages Edexcel
    2 主题
  10. Networks Edexcel
    7 主题
  11. Network Security Edexcel
    2 主题
  12. Environmental Issues Edexcel
    1 主题
  13. Ethical And Legal Issues Edexcel
    3 主题
  14. Cybersecurity Edexcel
    2 主题
  15. Develop Code Edexcel
    6 主题
  16. Constructs Edexcel
    4 主题
  17. Data Types And Data Structures Edexcel
    5 主题
  18. Operators Edexcel
    1 主题
  19. Subprograms Edexcel
    2 主题
课 Progress
0% Complete

Exam code:1CP2

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")

Responses

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