How to cryptographically hash a JSON object?

后端 未结 7 1704
醉话见心
醉话见心 2020-12-01 01:30

The following question is more complex than it may first seem.

Assume that I\'ve got an arbitrary JSON object, one that may contain any amount of data including oth

7条回答
  •  春和景丽
    2020-12-01 02:02

    Instead of inventing your own JSON normalization/canonicalization you may want to use bencode. Semantically it's the same as JSON (composition of numbers, strings, lists and dicts), but with the property of unambiguous encoding that is necessary for cryptographic hashing.

    bencode is used as a torrent file format, every bittorrent client contains an implementation.

提交回复
热议问题