Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python pleasee!! Topics: class, object, instantiation, print Problem Statement: Simple authentication system: In this assignment, we will be designing a simple authentication system. Authentication

in python pleasee!! image text in transcribed
Topics: class, object, instantiation, print Problem Statement: Simple authentication system: In this assignment, we will be designing a simple authentication system. Authentication is the process of validating a user, hence it requires a username and password like any web system we use. The purpose of this lab is to gain experience in python's basic class definition and object instantiation. Class Definition: You need to write a simple class 'User', where the class will have following instance variables and methods: 1. Instance variables: username and password, both of string type. 2. __init__method: constructor method to initialize instance variables. 3. _str_method: Print representation of 'User' object. The _str_function should print the username and password. Since password is a private information, it needs to be encrypted. For encryption the program will be using a simple scheme. The program will print password as series of asterisk (**) and length of the series will be the length of the password. For example, user 'John' has a password '1234567'. So, the password will be printed as seven asterisk. Please see below for a sample output. (Hint: 5*'A' will print 'A' five times) Note: The first parameter of all the methods in a class is 'self. 4. login(): This method returns True if a given username and password is valid otherwise returns False. Login method will check if the given username and matches with current object's instance variables. This method takes two parameters: given_username and given_passwrod. These two parameters are passed by user. Please see below. Object Creation/Instantiation and method calling: 1. You need to create two objects 'ul' and 'uz' of 'User' class where the username of ui is "john' and password is '1234567'. The second object v2 will have the username of "peter' and password is 'abcde'. 2. Print the information of two objects. 3. Call login function with u1 and pass "john' and '1234' as given_username and given_password. Check what this login function returns. Hint: It should return false since they do not match and the outcome should be 'Invalid login'. See sample output. 4. Call login function with u2 and pass 'peter and 'abcde' as given_username and given_password. Check what this login function returns. Hint: It should return True since they do match and the outcome should be 'Welcome peter'. See sample output. Sample output: Object created username: John password: ****** username: peter password: **** Invalid login #object ui invalid login Welcome peter #object u2 valid login

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What is a data structure in programming?

Answered: 1 week ago