0from name_that_hash import runner
1from tabulate import tabulate
2
3
4def identify_hash(filename):
5 with open(filename) as f:
6 hsh = f.read().split()[0]
7 return runner.api_return_hashes_as_dict([hsh], {"popular_only": True})
8
9
10def prettify_hash_info(hash_info):
11 res = []
12 headers = ["Name", "Hashcat", "John", "Extended", "Description"]
13 for key in hash_info.keys():
14 items = [
15 [i[k] if i[k] is not None else "-" for k in i.keys()]
16 for i in hash_info[key]
17 ]
18 table = f"Input hash: {key}, possible types:\n"
19 table += tabulate(items, headers, tablefmt="fancy_grid")
20 res.append(table)
21 return res