How to calculate a hash of a set (unordered list) of values?

I want to calculate the sha1 hash of a set (unordered list) of elements. I have already calculated the sha1 hash of each element. I am considering two solutions:

  • Sort items by their hashes and calculate the top hash of such a list.

  • Processing hashes of elements in the form of 160-bit integer values ​​and XOR (bitwise operation) together in a single hash of hash bits.

The second solution is weaker in terms of the properties of the secure hash function? (preliminary image resistance, second preliminary image resistance, collision resistance).

+4
source share
2 answers

1 - , ERS: -, node -, - ; , . , , .

2 : - 160- , 160 , - GF (2) 160 -. .

3, @paj28 ( , ) , "" . , hash , "bar" "foo", , , "ba" "rfoo". - , .

1: , - .


2: . , k n , XOR k-1 ( ). v; , XOR k , 2 k-n , k < . v k , ( , 1-2 kn), : k + 1 .

Recurse: n n , . , , n , 0. n .

( , , - ).

k , v k , . , , n XORed , v '. , n m i, h (m i) , n- t, , h (m i) XORed , t. m i t.

+7

(3) , , , , .

2 . , , .

, 1 3 . 3, , .

0

All Articles