MD5 etc. as a hash function

后端 未结 4 2046
逝去的感伤
逝去的感伤 2021-01-19 23:30

Let\'s say you are planning to design a hash function which will generate keys between 0-256. Will using first 2 digits of MD5-digest be a great idea for a uniform distribut

4条回答
  •  萌比男神i
    2021-01-20 00:10

    MD5 is designed to uniformaly spread the input over all the output bytes so it's as good as any other general hash function - sounds like a bit of overkill if you only want 256 values.

    Note the output of MD5 is 128bytes (16bytes), it's only the text representation that is hex digits - so there is really no first two digits of MD5 - just use the bottom 8bits.

提交回复
热议问题