-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexodus.py
39 lines (30 loc) · 1.12 KB
/
exodus.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
from Crypto.Hash import keccak
def decode_hex_to_ascii(txKey):
try:
# Decode from hexadecimal to bytes
txKey_bytes = bytes.fromhex(txKey)
# Attempt to convert bytes to ASCII string
decoded_string = txKey_bytes.decode('ascii')
return decoded_string
except UnicodeDecodeError:
# If it's not ASCII, we'll return None
return None
def calculate_keccak256(txKey):
# Convert the hex string to bytes
txKey_bytes = bytes.fromhex(txKey)
# Calculate the Keccak256 hash
k = keccak.new(digest_bits=256)
k.update(txKey_bytes)
# Return the hash in hexadecimal format
return k.hexdigest()
# Example txKey (provided by you)
txKey = "###"
# Step 1: Try decoding the txKey from Hex to ASCII (if applicable)
decoded_ascii = decode_hex_to_ascii(txKey)
if decoded_ascii:
print(f"Decoded ASCII: {decoded_ascii}")
else:
print("The txKey cannot be decoded to ASCII.")
# Step 2: Calculate the Keccak256 hash of txKey
calculated_hash = calculate_keccak256(txKey)
print(f"Calculated Keccak256 Hash: {calculated_hash}")