Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import messagebox
  3. import hashlib
  4. from pygame import mixer
  5.  
  6. window = tk.Tk()
  7. mixer.init()
  8.  
  9. HEIGHT = 500
  10. WIDTH = 600
  11.  
  12. window.title("Hashing Machine")
  13.  
  14. global hash_pass
  15.  
  16.  
  17. def about():
  18. tk.messagebox.showinfo("Details", "A simple hashing software written by Allexus M. Constantino using Python 3.7")
  19.  
  20.  
  21. def type_md5():
  22. global hash_pass
  23. hash_pass = hashlib.md5()
  24. print(hash_pass.hexdigest())
  25.  
  26.  
  27. def type_sha256():
  28. global hash_pass
  29. hash_pass = hashlib.sha256()
  30. print(hash_pass.hexdigest())
  31.  
  32.  
  33. def type_sha512():
  34. global hash_pass
  35. hash_pass = hashlib.sha512()
  36. print(hash_pass.hexdigest())
  37.  
  38.  
  39. def type_sha3_384():
  40. global hash_pass
  41. hash_pass = hashlib.sha3_384()
  42. print(hash_pass.hexdigest())
  43.  
  44.  
  45. def type_sha3_256():
  46. global hash_pass
  47. hash_pass = hashlib.sha3_256()
  48. print(hash_pass.hexdigest())
  49.  
  50.  
  51. def hash_it(pass_entry):
  52. mixer.music.load("sound.mp3")
  53. mixer.music.play()
  54. var = tk.StringVar()
  55. global hash_pass
  56. if hash_btn:
  57. if md5:
  58. type_md5()
  59. elif sha256:
  60. type_sha256()
  61. elif sha512:
  62. type_sha512()
  63. elif sha3_384:
  64. type_sha3_384()
  65. elif sha3_256:
  66. type_sha3_256()
  67.  
  68. hash_btn.flash()
  69. hash_pass.update(pass_entry.encode("UTF-8"))
  70. var.set("EQUIVALENT HASH: " + str(hash_pass.hexdigest()))
  71. entry_hash.config(textvariable=var)
  72. label_hash_name["text"] = ("CURRENT HASH ALGORITHM: ", hash_pass.name)
  73. label_hash_size["text"] = ("HASH SIZE(Bytes): ", hash_pass.digest_size)
  74. label_hash_internal_size["text"] = ("INTERNAL HASH BLOCK SIZE(BYTES): ", hash_pass.block_size)
  75. print(hashlib.algorithms_available)
  76.  
  77.  
  78. def how_to_use():
  79. tk.messagebox.showinfo("Usage", "Simply input a string of characters and choose the type of hash")
  80.  
  81.  
  82. menu_bar = tk.Menu(window)
  83. window.config(menu=menu_bar)
  84.  
  85. sub_menu = tk.Menu(menu_bar, tearoff=0)
  86. menu_bar.add_cascade(label="About", command=about)
  87. menu_bar.add_cascade(label="Help", menu=sub_menu)
  88. sub_menu.add_command(label="How to use", command=how_to_use)
  89.  
  90. sub_menu1 = tk.Menu(menu_bar, tearoff=0)
  91. menu_bar.add_cascade(label="Hash Type", menu=sub_menu1)
  92. md5 = sub_menu1.add_command(label="MD5", command=type_md5)
  93. sha256 = sub_menu1.add_command(label="SHA256", command=type_sha256)
  94. sha512 = sub_menu1.add_command(label="SHA512", command=type_sha512)
  95. sha3_384 = sub_menu1.add_command(label="SHA3_384", command=type_sha3_384)
  96. sha3_256 = sub_menu1.add_command(label="SHA3_256", command=type_sha3_256)
  97.  
  98. canvas = tk.Canvas(window, height=HEIGHT, width=WIDTH)
  99. canvas.pack()
  100.  
  101. # bg_image = tk.PhotoImage(file="background.png")
  102. # bg_label = tk.Label(window, image=bg_image)
  103. # bg_label.place(relwidth=1, relheight=1)
  104.  
  105. top_frame = tk.Frame(window, bd=5, bg="#999999")
  106. top_frame.place(relheight=0.25, relwidth=1.0)
  107.  
  108. input_label = tk.Label(top_frame, text="Input ----> ")
  109. input_label.place(x=5, relheight=0.25, relwidth=0.25)
  110.  
  111. pass_entry = tk.Entry(top_frame, bg="#666666", show="*", fg="white")
  112. pass_entry.place(relx=0.27, relwidth=0.73, relheight=0.25)
  113.  
  114. hash_btn = tk.Button(top_frame, text="HASHIFY!", bg="#336699", relief="ridge", activebackground="black",
  115. command=lambda: hash_it(pass_entry.get()))
  116. hash_btn.place(relx=0.40, y=60, relheight=0.25, relwidth=0.20)
  117.  
  118. entry_hash = tk.Entry(window, relief="solid", state="readonly", fg="red", font="bold")
  119. entry_hash.place(rely=0.20, relheight=0.10, relwidth=1.0)
  120.  
  121. btm_frame = tk.Frame(window, bg="#000000")
  122. btm_frame.place(rely=0.40, relheight=0.90, relwidth=1.0)
  123.  
  124. label_hash_name = tk.Label(window, relief="solid")
  125. label_hash_name.place(relx=0.25, rely=0.40, relheight=0.10, relwidth=0.5)
  126.  
  127. label_hash_internal_size = tk.Label(window, relief="solid")
  128. label_hash_internal_size.place(relx=0.25, rely=0.50, relheight=0.10, relwidth=0.5)
  129.  
  130. label_hash_size = tk.Label(window, relief="solid")
  131. label_hash_size.place(relx=0.25, rely=0.60, relheight=0.10, relwidth=0.5)
  132.  
  133. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement