repl.it
@JustARatherRidi/

Secure Login

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests, hashlib, os, time, binascii

def program():
    os.system('clear')
    print("""
     █████╗     ███████╗    ██╗   ██╗    ██████╗     ███████╗
    ██╔══██╗    ╚══███╔╝    ██║   ██║    ██╔══██╗    ██╔════╝
    ███████║      ███╔╝     ██║   ██║    ██████╔╝    █████╗  
    ██╔══██║     ███╔╝      ██║   ██║    ██╔══██╗    ██╔══╝  
    ██║  ██║    ███████╗    ╚██████╔╝    ██║  ██║    ███████╗
    ╚═╝  ╚═╝    ╚══════╝     ╚═════╝     ╚═╝  ╚═╝    ╚══════╝""")
    print("Welcome!")
    print("")
    print("Please choose from one of the options of what you want to do!")

def login():
    print("""
     █████╗     ███████╗    ██╗   ██╗    ██████╗     ███████╗
    ██╔══██╗    ╚══███╔╝    ██║   ██║    ██╔══██╗    ██╔════╝
    ███████║      ███╔╝     ██║   ██║    ██████╔╝    █████╗  
    ██╔══██║     ███╔╝      ██║   ██║    ██╔══██╗    ██╔══╝  
    ██║  ██║    ███████╗    ╚██████╔╝    ██║  ██║    ███████╗
    ╚═╝  ╚═╝    ╚══════╝     ╚═════╝     ╚═╝  ╚═╝    ╚══════╝""")
    print("")
    print("Please login with your registered username!")
    username = input("Username: ")
    password = input("Password: ")

    # Creating the Hash
    print("Creating the hash...")
    hash_username = hashlib.pbkdf2_hmac('sha256', bytes(username, 'utf-8'), b'salt', 150000)
    hash_password = hashlib.pbkdf2_hmac('sha256', bytes(password, 'utf-8'), b'salt', 150000)
    user_hex = binascii.hexlify(hash_username)
    pass_hex = binascii.hexlify(hash_password)
    the_hash = user_hex + pass_hex
    print("Hash Created!")

    #Checking the database
    print("Checking to see if you are in the database...")
    database = requests.get('http://xsecurity.000webhostapp.com/app/database.txt')


    if the_hash in database.content:
        print(f"[LOGGED IN] Welcome, {username}!")
        print("Redirecting you to the program...")
        time.sleep(4)
        program()

login()