How to cryptographically hash a JSON object?

后端 未结 7 1716
醉话见心
醉话见心 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 01:59

    I would do all fields in a given order (alphabetically for example). Why does arbitrary data make a difference? You can just iterate over the properties (ala reflection).

    Alternatively, I would look into converting the raw json string into some well defined canonical form (remove all superflous formatting) - and hashing that.

提交回复
热议问题