Fastest Hash Algorithm for Text Data

前端 未结 8 916
無奈伤痛
無奈伤痛 2020-12-08 11:25

I\'m trying to choose a hash algorithm for comparing about max 20 different text data.

Which hash is better for these requirements?

  • Less CPU Consumpti
8条回答
  •  天命终不由人
    2020-12-08 12:27

    How long does the hash need to hold for? GetHashCode() is pretty accessible, gives a small response (4 bytes), which should be fine (re minimizing collisions) over 20 strings.

    However, GetHashCode() should not be persisted to database - it is fine for in-memory comparisons, though. Just be aware that the algorithm may change between frameworks (and did between 1.1 and 2.0).

    The other advantage of this is that it is trivial to use - just use a Dictionary, which will deal with all the hashing etc for you.

提交回复
热议问题