-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMobileHashGen.py
More file actions
92 lines (77 loc) · 2.78 KB
/
MobileHashGen.py
File metadata and controls
92 lines (77 loc) · 2.78 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
# ****************************************************************************************
# Title: Hash Generator *******************************************************
# Developed by: Ryan Hatch *******************************************************
# Date: August 10th 2023 *******************************************************
# Last Updated: August 12th 2023 *******************************************************
# Version: 1.2 *******************************************************
# ****************************************************************************************
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(" 1. clear clipboard")
print(" 2. copy output to clipboard")
print(" 3. Generate new hash")
print(" 4. Decode hash")
print(" 5. exit program")
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("Enter the hash to decode: ")
decoded_text = input("Enter the original text that was hashed: ")
sha256_hash = hashlib.sha256(decoded_text.encode()).hexdigest()
if sha256_hash == input_hash:
print("\nHash successfully decoded.")
else:
print("\nDecoding unsuccessful. Hash does not match.")
except:
print("\nError during decoding.")
# ascii_banner = pyfiglet.figlet_format("SHA-" + "256".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:")
print("-" * 50)
print(sha256_hash)
print("-" * 50)
print_menu()
answer = input("\n\nagain? (y/n): ").lower()
if answer == "n" or answer == "no":
break
except:
print("\nerror: invalid input.")
input("\npress enter to exit.")