!pip install texttable
Requirement already satisfied: texttable in /usr/local/lib/python3.7/site-packages (1.6.2)
from getpass import getpass
import hashlib
from texttable import Texttable
LOGO = r"""
█████╗███╗ █████╗ ██╗ ██████╗██████████████╗
██╔══██████╗ ██████║ ██║ ██╔═══████╔════██╔════╝
█████████╔████╔████║ █████████║ ████████████████╗
██╔══████║╚██╔╝████║ ██╚════██║ ██╚════██╚════██║
██║ ████║ ╚═╝ ██╚██████╔╝ ╚██████╔██████████████║
╚═╝ ╚═╚═╝ ╚═╝╚═════╝ ╚═════╝╚══════╚══════╝
"""
def validate_name(name):
for part in name.split():
if not part.isalpha():
return False
return True
def take_name_input(prompt):
name = input(prompt)
while not validate_name(name):
print("You did not enter the name correctly, please try again!")
name = input(prompt)
return name
def print_id(u_info):
table = Texttable()
table.add_rows([[f"{LOGO} \n MEMBER - {u_info[0]}"],
[f"Slack Username: {u_info[1]}"],
[f"MOTHER'S NAME: {u_info[2]}"],
[f"FATHER'S NAME: {u_info[3]}"]
])
print(table.draw())
def read_hash(filename):
with open(filename, "r") as f:
hash = f.readline()
return hash
def authenticate(password):
correct_hash = read_hash("hashed_password.txt")
hashed_password = hashlib.sha256(password.encode('utf-8')).hexdigest()
if hashed_password == correct_hash:
print("[INFO] Successfully authenticated!")
return True
print("Authentication failed! You cannot print ID")
return False
def get_user_info():
u_info = []
u_info.append(take_name_input("Name of applicant: "))
u_info.append(input("Slack username: "))
u_info.append(take_name_input("Mother's name: "))
u_info.append(take_name_input("Father's name: "))
return u_info
def main():
password = getpass("Enter admin password: ")
if authenticate(password):
u_info = get_user_info()
print_id(u_info)
if __name__ == '__main__':
main()
Enter admin password: ········ [INFO] Successfully authenticated! Name of applicant: Rahul Jha Slack username: RJ722 Mother's name: Kumkum Jha Father's name: Rajeev Kumar Jha +-------------------------------------------------------+ | | | | | █████╗███╗ █████╗ ██╗ ██████╗██████████████╗ | | ██╔══██████╗ ██████║ ██║ ██╔═══████╔════██╔════╝ | | █████████╔████╔████║ █████████║ ████████████████╗ | | ██╔══████║╚██╔╝████║ ██╚════██║ ██╚════██╚════██║ | | ██║ ████║ ╚═╝ ██╚██████╔╝ ╚██████╔██████████████║ | | ╚═╝ ╚═╚═╝ ╚═╝╚═════╝ ╚═════╝╚══════╚══════╝ | | | | | | MEMBER - Rahul Jha | +=======================================================+ | Slack Username: RJ722 | +-------------------------------------------------------+ | MOTHER'S NAME: Kumkum Jha | +-------------------------------------------------------+ | FATHER'S NAME: Rajeev Kumar Jha | +-------------------------------------------------------+