Skip to content

Instantly share code, notes, and snippets.

@vivithemage
Created July 27, 2020 00:05
Show Gist options
  • Save vivithemage/cabfd715742b99eafbcb624e4d1152ce to your computer and use it in GitHub Desktop.
Save vivithemage/cabfd715742b99eafbcb624e4d1152ce to your computer and use it in GitHub Desktop.
import hashlib
import sys
def md5Experiment(domain_name, total_shards):
hash_obj = hashlib.md5(domain_name)
digest = hash_obj.hexdigest()
shard_id = int(digest, 16) % total_shards
return shard_id
argument = str.encode(sys.argv[1])
print(str(md5Experiment(argument, 64)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment