Advertisement
xample

Simple login example

Jun 12th, 2019
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.60 KB | None | 0 0
  1. #PY3
  2. import subprocess
  3. import hashlib
  4. import base64
  5. from urllib.request import urlopen
  6. import tkinter as tk
  7. from tkinter import messagebox
  8. def encode_with_hwid(string,hwid_):
  9.     sha = (hashlib.sha512(bytes(str(string).encode('utf-8') + hwid_.encode('utf-8'))).hexdigest())
  10.     return (base64.b64encode(sha.encode('utf-8'))).decode() # SHA 512 Encryption
  11. def get_hwid():
  12.     return str(subprocess.check_output('wmic csproduct get uuid')).split('\\r\\n')[1].strip('\\r').strip() # WINDOWS SUPPORTED ONLY! so if lin systems are different
  13. def checkLogin(key):
  14.     HWID = get_hwid()
  15.     ENCODED = (encode_with_hwid(key,HWID))
  16.     if ENCODED in db:
  17.         messagebox.showinfo("Welcome!","You've been logged in successfully!")
  18.     else:
  19.         messagebox.showinfo("Incorrect information!","Either you've inputed the wrong key or it doesn't exist.", icon = 'error')
  20.     return
  21. # Getting database...
  22. db = urlopen("https://pastebin.com/raw/j9tEQPt0").read().decode().split()
  23.  
  24. # Setting up the GUI
  25. class loginPage(tk.Frame):
  26.     def __init__(self, master = None):
  27.         tk.Frame.__init__(self,master)
  28.         self.page_settings()
  29.         self.title()
  30.         self.key_label()
  31.         self.key_entry()
  32.         self.login_button()
  33.         self.master.mainloop()
  34.     def page_settings(self):
  35.         self.master.geometry("400x200") # W x H
  36.         self.master.title("Login Page - Example")
  37.         self.master.resizable(width = False, height = False)
  38.         self.master.attributes('-topmost', True)
  39.         self.master.configure(background = 'black')
  40.     def title(self):
  41.         T = tk.Label(self.master, text = "Login Page")
  42.         T.configure(background = 'black', foreground = 'green', font = ('Arial Black',20,'bold','underline'))
  43.         T.place(x = 200, y = 20, anchor = 'center')
  44.     def key_label(self):
  45.         username_field = tk.Label(self.master, text = "Key")
  46.         username_field.configure(background = 'black', foreground = 'white', font = ('Arial Black',12,'bold'))
  47.         username_field.place(x = 0, y = 50)
  48.         required_mark = tk.Label(self.master, text = "*")
  49.         required_mark.configure(background = 'black', foreground = 'red', font = ('Arial Black',12,'bold'))
  50.         required_mark.place(x = 40, y = 50)
  51.     def key_entry(self):
  52.         global entry
  53.         entry = tk.Entry(self.master)
  54.         entry.configure(background = 'black', foreground = 'white', font = ('Arial Black',12,'bold'))
  55.         entry.place(x = 0, y = 80)
  56.     def login_button(self):
  57.         LOGIN_B = tk.Button(self.master, text = "Sign in", command = lambda:checkLogin(entry.get()))
  58.         LOGIN_B.configure(background = 'black', foreground = 'red', font = ('Arial Black',12,'bold'), borderwidth = 0)
  59.         LOGIN_B.place(x = 200, y = 170, anchor = 'center', width = 180)
  60.  
  61. mainPage = tk.Tk()
  62. loginPage(master = mainPage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement