MD5 etc. as a hash function

后端 未结 4 2008
逝去的感伤
逝去的感伤 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条回答
  •  星月不相逢
    2021-01-20 00:03

    There's no reason to use a cryptographic strength hash for something as simple as generating 3 digit hashes. You're better off using a more simple hash there.

    I'm not certain specifically how expensive MD5 is relative to others, but there are plenty of better ways to create a small hash (see this article for some algorithm ideas).

提交回复
热议问题