Password-based Authentication

Password-based authentication is a security mechanism where a user gains access to a system or application by entering a password that matches the one stored in the system's database.

# Example of password-based authentication in Python

# Simulated user database
user_db = {"username": "user1", "password": "securepassword123"}

def authenticate(username, password):
    if username in user_db and user_db["password"] == password:
        return "Authentication successful!"
    else:
        return "Authentication failed!"

# User input
input_username = input("Enter username: ")
input_password = input("Enter password: ")

# Authentication check
print(authenticate(input_username, input_password))

This code snippet simulates a basic password-based authentication process by checking the entered username and password against a predefined user database.

Last updated