Skip to content

Instantly share code, notes, and snippets.

@leoluyi
Last active June 26, 2018 08:59
Show Gist options
  • Select an option

  • Save leoluyi/ae561a8ac907a1b6f60d5a185345aaf4 to your computer and use it in GitHub Desktop.

Select an option

Save leoluyi/ae561a8ac907a1b6f60d5a185345aaf4 to your computer and use it in GitHub Desktop.
Hashing a dictionary
import hashlib
import json
m = hashlib.sha256()
data_json = json.dumps(data_dict, ensure_ascii=False, sort_keys = True)
m.update(str(data_json).encode('utf-8'))
hashed = m.hexdigest()
print(hashed)
instance.id = hashed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment