Password-based Authentication
# 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))Last updated