Last active
June 26, 2018 08:59
-
-
Save leoluyi/ae561a8ac907a1b6f60d5a185345aaf4 to your computer and use it in GitHub Desktop.
Hashing a dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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