Python comes in very handy when dealing with data, for data crunching, machine learning,
interactions on the web.
Today we aim to make a authentication mechanism using Python.
Using python dictionaries to simulate database for user information.
Give the user two options,
a. Add new User
b. Log In with existing credentials
a. For new user registration in system, input parameters are
NAME,ROLL,EMAIL,PASSWORD(comma separated values).
Validate entries as-
- email Id – email id acceptable(SOMEONE@students.devinline.ac.in)
- Password length at least 8 characters
- Roll number should be a integer [optional if you do not know python regex]
If valid entry- print “Success”
Else print - “Registration Failed”
b. For logging in, input parameters are ROLL/EMAIL,PASSWORD
Input can be roll number or email, both are valid.
If authentication is successful print “Login Success”
Else print “Login Fails”
Sample Output:-
>>>
Welcome to Devinline authentication system
Choose:
1-Register New User
2-Log In
Any other - Exit program
1
Enter name, rollNo, password, email(Separated by comma)
alia,20160047,alia@students.devinline.ac.in,**alia**
Success
Enter your choice(1|2)
2
Enter loginId(Roll or Email) and password
20160047,**alia**
Login Success!!
interactions on the web.
Today we aim to make a authentication mechanism using Python.
Using python dictionaries to simulate database for user information.
Give the user two options,
a. Add new User
b. Log In with existing credentials
a. For new user registration in system, input parameters are
NAME,ROLL,EMAIL,PASSWORD(comma separated values).
Validate entries as-
- email Id – email id acceptable(SOMEONE@students.devinline.ac.in)
- Password length at least 8 characters
- Roll number should be a integer [optional if you do not know python regex]
If valid entry- print “Success”
Else print - “Registration Failed”
b. For logging in, input parameters are ROLL/EMAIL,PASSWORD
Input can be roll number or email, both are valid.
If authentication is successful print “Login Success”
Else print “Login Fails”
Sample code - Simulate Login and Registration using Dict
import re class Students: def __init__(self, name, rollNo, email, password): self.name = name self.rollNo = rollNo self.email = email self.password = password def doDBOperation(choice,studentDict1,studentDict2): if choice == 1: print "Enter name, rollNo, password, email(Separated by comma)" inputArr = map(str,raw_input().strip().split(',')) name=inputArr[0] rollNo=inputArr[1] email=inputArr[2] password=inputArr[3] #print name, rollNo, password, email stat = adduser(name, rollNo, email,password) if stat == "SUCCESS": student = Students(name, rollNo, email, password) studentDict1[rollNo] = student studentDict2[email] = student print "Success" else: print "Registration Failed" elif choice == 2: print "Enter loginId(Roll or Email) and password" inputArr = map(str,raw_input().strip().split(',')) rollorEmail=inputArr[0] password=inputArr[1] stat=loginService(studentDict1,studentDict2, rollorEmail, password) if stat == "SUCCESS": print "Login Success!!" else: print "Login Fails !!" print "Enter your choice(1|2)" def adduser(name, rollNo, email, password): if validateEmail(email) and validatePassword(password) and validateRollNo(rollNo) : return "SUCCESS" else: return "FAILURE" def loginService(studentDict1,studentDict2,rollorEmail,pwd): if studentDict1.has_key(rollorEmail) or studentDict2.has_key(rollorEmail): if studentDict1.has_key(rollorEmail): studentObj = studentDict1[rollorEmail] else: studentObj = studentDict2[rollorEmail] if studentObj.password == pwd: return "SUCCESS" else: return "FAILURE" def validateEmail(email): pattern = "^[a-z]+[.]?[a-z]*@students.devinline.ac.in" prog = re.compile(pattern) result = prog.match(email) if result != None: return True else: return False def validateRollNo(rollNo): rollNo = str(rollNo) return rollNo.isdigit() def validatePassword(password): if len(password) >= 8: return True else: return False if __name__ == "__main__" : studentDict1 = { } studentDict2 = { } print "Welcome to Devinline authentication system"\ "\nChoose:\ \n1-Register New User\ \n2-Log In \ \nAny other - Exit program" while True: choice=int(input()) if choice == 1 or choice == 2: doDBOperation(choice,studentDict1,studentDict2) else : print "OK Bye" break
Sample Output:-
>>>
Welcome to Devinline authentication system
Choose:
1-Register New User
2-Log In
Any other - Exit program
1
Enter name, rollNo, password, email(Separated by comma)
alia,20160047,alia@students.devinline.ac.in,**alia**
Success
Enter your choice(1|2)
2
Enter loginId(Roll or Email) and password
20160047,**alia**
Login Success!!
This blog was making more interesting. Keep adding more information on your page.
ReplyDeleteC C++ Training in Chennai
c c++ classes
C C++ Training in OMR
C C++ Training in Adyar
JMeter Training in Chennai
Appium Training in Chennai
javascript training in chennai
core java training in chennai
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
DeletePython Projects for Students
Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.
Project Center in Chennai
ReplyDeleteI really enjoyed this article. I need more information to learn so kindly update it.
Selenium Training in Chennai
best selenium training in chennai
selenium classes in chennai
best selenium training in chennai
Selenium Training in Tnagar
Selenium training in Thiruvanmiyur
Big data training in chennai
Software testing training in chennai
Android Training in Chennai
JAVA Training in Chennai
Great Article. Thank you for sharing! Really an awesome post for every one.
ReplyDeleteIEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.
Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai
Nice blog! Thanks for sharing this valuable information
ReplyDeleteGerman Classes in Chennai
German Classes in Bangalore
German Classes in Coimbatore
German Classes in Madurai
German Language Course in Hyderabad
German Courses in Chennai
German Courses in Bangalore
German Courses in Coimbatore
German classes in marathahalli
Tally Course in Coimbatore
Here is the colleges details to study in Bangalore. You can select the best college details from the below mentioned courses that you love to study. The list of colleges are only in Bangalore, so, if you are looking to study in Bangalore, just click the below mentioned links.
ReplyDeleteBSc Medical Imaging Technology Colleges in Bangalore | Medical Imaging Technology Colleges in Bangalore | BSc Optometry Colleges in Bangalore | Optometry Colleges in Bangalore |BSc Renal Dialysis Colleges in Bangalore | Renal Dialysis Technology Colleges in Bangalore |BSc Respiratory Care Technology Colleges in Bangalore | Respiratory Care Colleges in Bangalore |BSc Cardiac Care Technology Colleges in Bangalore | Cardiac Care Colleges in Bangalore |BSc Perfusion Technology Colleges in Bangalore | Perfusion Technology Colleges in Bangalore |
Taldeen is one of the best plastic manufacturing company in Saudi Arabia. They are manufacturing Handling Solutions Plastic products like Plastic Pallets and plastic crates. Here is the link of the product
ReplyDeleteHandling Solutions
Plastic Pallets
GrueBleen is one of the Branding and Marketing agency Based in Riyadh- Saudi Arabia. The main functions of GrueBleen is Advertising, Branding, Marketing, Office Branding, Exhibition Management and Digital Marketing. Visit the below link to know more about GrueBleen Creative Club.
Branding Agency Riyadh
Marketing Agency Riyadh
Agriculture Solutions – Taldeen is a plastic manufacturing company in Saudi Arabia. They are manufacturing agricultural plastic products like greenhouse cover and hay cover. Visit the below link to know more details
Agriculture Solutions
Greenhouse Cover
GrueBleen – One of the best social media marketing agency in Riyadh- Saudi Arabia. Visit here for the all service details of GrueBleen.
Social Media Marketing Agency | Social Media Agency In Saudi Arabia | Social Media Agency In Riyadh | Social Media Agency in Jeddah |
Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Oracle Training In Chennai , Oracle PLSQL Training In Chennai , Oracle DBA Training In Chennai , AWS Training in Chennai & get to know everything you want to about software trainings.
ReplyDeleteMua vé tại đại lý vé máy bay Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ giá bao nhiêu
mua vé về việt nam
Vé máy bay từ Úc về Việt Nam
đăng ký vé máy bay từ nhật về việt nam
bay từ đức về việt nam mấy tiếng
Are you looking for Big Data training in Chennai with placement opportunities? Then we, Infycle Technologies are with you to make your dream into reality. Infycle Technologies is one of the best Big Data Training Institute in Chennai, which offers various programs along with Big Data such as Oracle, Java, AWS, Hadoop, etc., in complete hands-on practical training with trainers, those are specialists in the field. In addition to the training, the mock interviews will be arranged for the candidates, so that they can face the interviews with the best knowledge. Of all that, 100% placement assurance will be given here. To have the words above in the real world, call 7502633633 to Infycle Technologies and grab a free demo to know more.Big Data Training in Chennai | Infycle Technologies
ReplyDeleteAbsolutely knowledgeable content. Thanks for sharing this kind of content. One of the best blogs to study programming I've come across. It is very helpful and very informative and I really learned a lot from it. Great blog. Data structures and algorithms in Python
ReplyDeleteGrab the Selenium Training in Chennai from Infycle Technologies, the best software training institute in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Java, Hadoop, Big Data, Android, and iOS Development, Oracle, etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career. Get Selenium Course in Chennai | Infycle Technologies
ReplyDelete
ReplyDeleteTo keep current, you need to find trustworthy technology news sources that will provide you with up-to-date information.
blackboard san jac
inverse function calculator
qhs medical abbreviation
very informative. thank you. please check this out software training
ReplyDelete