algorithm - calculating a hash of a data structure? -
Suppose I want to calculate the hash of a data structure using a hash algorithm such as MD5 which is serial Accept the stream for the purpose of checking the equivalence (I want to record the hash, then want to re-do the hash on the same or an equivalent data structure, and hash to measure equivalence with high probability Investigating.)
Do not Do It The methods?
Problems I can see that are problematic
- If there is an array of binary string in the data structure, then I add them after ["abc", "defg Can not "] and [" AB "," CDF "] are not equivalent arrays
- If there is a collection of data structures which are not guaranteed in the same sequence, e.g. A key-value dictionary {a: "bc", d: "efg", h: "ijkl"} that should be considered as a key-value pair {d: "efg", h: "ijkl", a: "BC"}.
For the first digit, the length of the string hash too. This will separate their swan
For the second, sort the keys
Comments
Post a Comment