Skip to content

Commit f1b6c2d

Browse files
committed
updated sha256 hash json function to remove whitespace, matching JavaScript's JSON.stringify()
1 parent 1c78781 commit f1b6c2d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/rid_lib/ext/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
def sha256_hash_json(data: dict | BaseModel):
1111
if isinstance(data, BaseModel):
1212
data = json.loads(data.model_dump_json())
13-
json_bytes = json.dumps(data, sort_keys=True).encode()
13+
json_str = json.dumps(data, separators=(',', ':'), sort_keys=True)
14+
json_bytes = json_str.encode()
1415
hash = hashlib.sha256()
1516
hash.update(json_bytes)
1617
return hash.hexdigest()

0 commit comments

Comments
 (0)