Skip to content

Commit

Permalink
SQL Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
astechedu committed Mar 21, 2024
1 parent 8067655 commit 9640a4a
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions sqlphp/developer-notes/python/core.python/python.login.signup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
>>>>> Python Login & Sign Up <<<<<


----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------

1. basic Login & Sign UP for beginners
https://medium.com/@moinahmedbgbn/a-basic-login-system-with-python-746a64dc88d6

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------

>>> 1. A Basic Login System with Python

Concept

The program will accept the user’s email and password, hash the password, store it into a text file with the email, and complete the registration process.


Prerequisites

You should have installed python version 3.0 or above to use the built-in package hashlib.


import hashlib
def signup():
email = input(“Enter email address: “)
pwd = input(“Enter password: “)
conf_pwd = input(“Confirm password: “) if conf_pwd == pwd:
enc = conf_pwd.encode()
hash1 = hashlib.md5(enc).hexdigest() with open(“credentials.txt”, “w”) as f:
f.write(email + “\n”)
f.write(hash1)
f.close()
print(“You have registered successfully!”) else:
print(“Password is not same as above! \n”)def login():
email = input(“Enter email: “)
pwd = input(“Enter password: “) auth = pwd.encode()
auth_hash = hashlib.md5(auth).hexdigest()
with open(“credentials.txt”, “r”) as f:
stored_email, stored_pwd = f.read().split(“\n”)
f.close() if email == stored_email and auth_hash == stored_pwd:
print(“Logged in Successfully!”)
else:
print(“Login failed! \n”)while 1:
print("********** Login System **********")
print("1.Signup")
print("2.Login")
print("3.Exit")
ch = int(input("Enter your choice: "))
if ch == 1:
signup()
elif ch == 2:
login()
elif ch == 3:
break
else:
print("Wrong Choice!")

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------

0 comments on commit 9640a4a

Please sign in to comment.