Skip to content

Instantly share code, notes, and snippets.

@thomasthaddeus
Created June 24, 2024 16:56
Show Gist options
  • Save thomasthaddeus/892402d6bea7d309aaa4dfee3822c09e to your computer and use it in GitHub Desktop.
Save thomasthaddeus/892402d6bea7d309aaa4dfee3822c09e to your computer and use it in GitHub Desktop.
This is a quick implementation of how to get the hashes for everything in the HASHES list for all of the hashes types in the hashesTYPES
import hashlib
HASHES = ["BilboBaggins2012", "SamGamgee2013", "GandalfGrey2014"]
def print_hashes(data_list, hash_name):
hash_func = getattr(hashlib, hash_name)
digests = list(map(lambda data: hash_func(data.encode('utf-8')).hexdigest(), data_list))
print(f"\n{hash_name.upper()} Hashes:")
print("\n".join(f"{data}: {digest}" for data, digest in zip(data_list, digests)))
HASH_TYPES = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'blake2b', 'blake2s']
[print_hashes(HASHES, hash_name) for hash_name in HASH_TYPES]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment