Exercise 11.3.3
Consider a version of the division method in which h(k)=kmodm, where
m=2p−1 and k is a character string interpreted in radix 2p. Show
that if we can derive string x from string y by permuting its characters,
then x and y hash to the same value. Give an example of an application in
which this property would be undesirable in a hash function.
We need to observe that the hash of the string is the sum of the hashes of each
character, and it does not depend on the order they are in. If x=⟨xn,…,x1,x0⟩.
h(x)=(i=0∑nxi2ip)modm=i=0∑n(ximodm)(2ipmod(2p−1))=i=0∑n(ximodm)(1∏i(2pmod(2p−1)))=i=0∑n(ximodm)(1∏i1)=i=0∑n(ximodm)
We can put the elements of x in any other order, and the result will still be
the same.