Detect changes in random ordered input (hash function?)

Question :

Detect changes in random ordered input (hash function?),

Answer :

I’m reading lines of text that can come in any order. The problem is that the output can actually be indentical to the previous output. How can I detect this, without sorting the output first?

Is there some kind of hash function that can take identical input, but in any order, and still produce the same result?

,

The easiest way would seem to be to hash each line on the way in, storing the hash and the original data, and then compare each new hash with your collection of existing hashes. If you get a positive, you could compare the actual data, to make sure it’s not a false positive – though this would be extremely rare, you could go with a quicker hash algorithm, like MD5 or CRC (instead of something like SHA, which is slower but less likely to collide), just so it’s quick, and then compare the actual data when you get a hit.

Read More  National holiday web service

That’s the answer Detect changes in random ordered input (hash function?), Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you