-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashGen.py
More file actions
96 lines (80 loc) · 3.58 KB
/
HashGen.py
File metadata and controls
96 lines (80 loc) · 3.58 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# ****************************************************************************************
# Title: Hash Generator *******************************************************
# Developed by: Ryan Hatch *******************************************************
# Date: August 10th 2023 *******************************************************
# Last Updated: October 6th 2023 *******************************************************
# Version: 1.3 *******************************************************
# ****************************************************************************************
import hashlib
import getpass
import pyfiglet
import os
def clear_clipboard():
os.system("echo off | clip")
print("\n\nClipboard Cleared.")
def copy_to_clipboard(text):
os.system(f"echo {text} | clip")
print("\n\nOutput Copied To Clipboard.")
def print_menu():
print("\n\n\n")
print("****************************************************************************************\n")
print("* 1 | Clear Clipboard |***************************************************************\n")
print("* 2 | Copy Output |***************************************************************\n")
print("* 3 | Generate New Hash |***************************************************************\n")
print("* 4 | Decode |***************************************************************\n")
print("* 5 | Exit |***************************************************************\n")
print("****************************************************************************************\n")
answer = input("\n\nEnter Option: ")
if answer == "1":
clear_clipboard()
elif answer == "2":
copy_to_clipboard(sha256_hash)
elif answer == "3":
pass # Restart program
elif answer == "4":
decode_hash() # Call the decode_hash function
elif answer == "5":
pass # Exit program
else:
print("\nInvalid Input.")
def decode_hash():
try:
input_hash = input("\nEnter The Hash To Decode: ")
decoded_text = input("\nEnter The Original Text That Was Hashed: ")
sha256_hash = hashlib.sha256(decoded_text.encode()).hexdigest()
if sha256_hash == input_hash:
print("\n\nHash Successfully Decoded.")
else:
print("\n\nDecoding Unsuccessful. Hash Does Not Match.")
except:
print("\n\nError During Decoding.")
ascii_banner = pyfiglet.figlet_format("HASH " + "- GEN".upper())
print(ascii_banner.lower())
print(" /\\")
print(" /__\\")
print(" /\\ /\\")
print(" /__\\/__\\")
print(" /\\ /\\")
print(" /__\\ /__\\")
print(" /\\ /\\ /\\ /\\")
print(" /__\\/__\\/__\\/__\\")
counter = 0
while True:
text = getpass.getpass(prompt="\n\n. . . . . .")
if text == 'exit':
break
counter += 1
print(f"\n--- session {counter} ---")
try:
sha256_hash = hashlib.sha256(text.encode()).hexdigest()
print("\n\nOutput:\n")
print("-" * 80)
print(sha256_hash)
print("-" * 80)
print_menu()
answer = input("\n\nRun Again? (Y/N): ").lower()
if answer == "n" or answer == "no":
break
except:
print("\nError: Invalid Input.")
input("\nPress Enter To Exit.")