Good choice for a lightweight checksum algorithm?

后端 未结 9 1677
礼貌的吻别
礼貌的吻别 2020-12-30 06:04

I find myself needing to generate a checksum for a string of data, for consistency purposes. The broad idea is that the client can regenerate the checksum based on the payl

9条回答
  •  长发绾君心
    2020-12-30 06:32

    CRC32 is not too hard to implement in any language, it is good enough to detect simple data corruption and when implemted in a good fashion, it is very fast. However you can also try Adler32, which is almost equally good as CRC32, but it's even easier to implement (and about equally fast).

    Adler32 in the Wikipedia

    CRC32 JavaScript implementation sample

    Either of these two (or maybe even both) are available in Java right out of the box.

提交回复
热议问题