Promail register login

Here is an example of a simple PROMAIL register and login system in Python:

promail.py

import getpass
import hashlib
import os

# Database to store user credentials
users = {}

def register():
    username = input("Enter a username: ")
    password = getpass.getpass("Enter a password: ")
    password_hash = hashlib.sha256(password.encode()).hexdigest()
    users[username] = password_hash
    print("Account created successfully!")

def login():
    username = input("Enter your username: ")
    password = getpass.getpass("Enter your password: ")
    password_hash = hashlib.sha256(password.encode()).hexdigest()
    if username in users and users[username] == password_hash:
        print("Login successful!")
    else:
        print("Invalid username or password!")

def main():
    while True:
        print("1. Register")
        print("2. Login")
        print("3. Quit")
        choice = input("Choose an option: ")
        if choice == "1":
            register()
        elif choice == "2":
            login()
        elif choice == "3":
            break
        else:
            print("Invalid option!")

if __name__ == "__main__":
    main()

Here's how the code works:

  1. The users dictionary stores the user credentials, where each key is a username and each value is the corresponding password hash.
  2. The register function prompts the user to enter a username and password, and then stores the password hash in the users dictionary.
  3. The login function prompts the user to enter their username and password, and then checks if the username exists in the users dictionary and if the password hash matches the stored hash.
  4. The main function is the main loop of the program, which repeatedly prompts the user to choose an option: register, login, or quit.

Note that this is a very basic implementation and you should consider adding additional security measures, such as:

Also, this code is for educational purposes only and should not be used in production without proper security measures.