http://qs321.pair.com?node_id=962893


in reply to Re: [OT] The statistics of hashing.
in thread [OT] The statistics of hashing.

I only bring this up because I think you started out with the same assumption about MD5, ...

That is a very good point.

The distribution of any (perfect(*)) hashing algorithm will only be fully utilised if the inputs can take on all possible values for any given input length.

For example, ASCII or ISO text, certain parts of the input range -- many of the control characters <32; and characters >126 -- will not appear in the inputs, so for any given length, the range of inputs to the hashing algorithm is biased. It stand to reason that the outputs will similarly biased and the full range of the hash values will not be produced.

It is also the case that for any given input language, there are some character combinations that will never appear in normal text -- eg. ZXZXZXZXZXZXZXZXZXZ -- hence the inputs, and thus outputs will be further biased.

For this particular part of the exercise, I'm more concerned with the collision detection mechanism than the vagaries of the hashing.

But thank you for raising the issue. I may well contact you later for the details of your SimCRC64 algorithm.

(*)Note: I am aware that MD5 is probably far from perfect.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^3: [OT] The statistics of hashing.
by flexvault (Monsignor) on Apr 02, 2012 at 08:45 UTC

    BrowserUk,

      ...ASCII or ISO text, certain parts of the input range -- many of the control characters <32; and characters >126 -- will not appear...
    I hadn't thought about it but since the files were encrypted, more character sequences might appear.

    As far as the 'SimCRC64' algorithm, it was just a simple CRC routine. I don't have the actual code, but it was something like this.

    my $crc = crc64(\$output); ## Add crc check to output data sub crc64 ## Add crc check to output data { my $data = shift; my $crc = ""; my $len = length($$data); my $pos + = 0; while ( $pos < $len ) { $crc = $crc ^ ( substr($$data,$pos,8) ); $pos += 8; } return ( $crc ); }

    It was part of the test to see what the worst case would be. As I previously said, I didn't expect the results.

    Thank you

    "Well done is better than well said." - Benjamin Franklin

      I don't have the actual code, but it was something like this.

      Thanks for posting that.

      However, for my purposes -- deterministically generating a randomly distributed value -- it doesn't work well. With the MD5, every single bit change in the input generates an average of 64-bits change in the output -- which is near perfect.

      But this crc algorithm -- which was probably great for your purposes -- only generates a single bit change in the output for each single bit change in the input:


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        BrowserUK,

        I had to download your code to figure out what you were doing, but now I know your interest in uniqueness was different than mine(i.e. project).

        Each of the test encrypted files was unique and we wanted an algorithm that would produce the lowest number of duplicate hashes for the different unique files. The statistics I showed was the number of duplicate hashes produced from unique files. Each hash was generated and then:

        ... $Dupes{$hash}++; ...
        Then we just counted the total number of keys with values greater than one.

        Your code was very interesting and quite a mind tester.

        Thank you

        "Well done is better than well said." - Benjamin Franklin