DEV Community

IEATCODE
IEATCODE

Posted on

How to make a login and sign up form in python

First start by installing the kittyscript library

pip install kittyscript
Enter fullscreen mode Exit fullscreen mode

then import these libraries

from kittyscript import *
import hashlib
Enter fullscreen mode Exit fullscreen mode

here I'm using hashlib to hash the passwords and kittyscript to verify emails.

then make two if statements

from kittyscript import *
import hashlib

S = input("Sign up or log in\n:")

if S == "Sign up":
    password = input("New Password\n:")
    NewUseremail = input("Your E-mail\n:")
    checkemail(NewUseremail)
    hashed_password = hashlib.sha256(password.encode('utf-8')).hexdigest()
    data = ["\n",NewUseremail, ",", hashed_password] 
    with open('index.csv', 'a', encoding='UTF8') as f:
        f.writelines(data)

if S == "Log In":
    Username = input("Your Username\n:")
    if Username in open('index.csv').read():
        Password = input("Your Password\n:")
        hashpass = hashlib.sha256(Password.encode('utf-8')).hexdigest()
        if hashpass in open('index.csv').read():
            print("Logged in")
        else:
            print("Invalid Username")
            exit()
    else:
        print("Invalid Username")
        exit()
Enter fullscreen mode Exit fullscreen mode

and done

Top comments (0)