From 31f3a4a5c388c7c021c103687fbc8c8a8a0be005 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Sat, 23 Mar 2019 21:13:14 +0530 Subject: [PATCH] Make the hash function for generic case --- mythril/support/support_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mythril/support/support_utils.py b/mythril/support/support_utils.py index 71178871..6912ddd3 100644 --- a/mythril/support/support_utils.py +++ b/mythril/support/support_utils.py @@ -31,9 +31,10 @@ def get_code_hash(code): :param code: bytecode :return: Returns hash of the given bytecode """ + code = code[2:] if code[:2] == "0x" else code try: keccak = sha3.keccak_256() - keccak.update(bytes.fromhex(code[2:])) + keccak.update(bytes.fromhex(code)) return "0x" + keccak.hexdigest() except ValueError: log.debug("Unable to change the bytecode to bytes. Bytecode: {}".format(code))