[erlang-questions] checksum calculation

Richard O'Keefe ok@REDACTED
Tue Apr 7 03:29:18 CEST 2009

On 6 Apr 2009, at 9:34 pm, Gamoto wrote:

> If it is not a very good solution, would you like to suggest a  
> better one, for me and the other readers ?\

Suppose you have a block of bytes and there is an
error that results in one byte being replaced by
a different byte.  Then an XOR checksum will detect
that difference.

Suppose there is an error that results in two bytes
being swapped.  Then an XOR checksum will detect no
change at all.  Or suppose that two equal bytes are
both replaced by the same new byte.  Again, nothing
noticed by XOR.

Just look "checksum" up in the Wikipedia; that's as
good a place as any to start.

The 'zlib' module in Erlang already has support for
crc32 and adler32.  I thought I saw crc32 somewhere
else as well.

Theory and practice don't agree as much in practice
as they do in theory, so it's worth having a look at
"Performance of Checksums and CRCs over Real Data"
by Jonathan Stone, Michael Greenwald, Craig Partridge,
and Jim Hughes
and at "Revisiting Fletcher and Adler Checksums"
by Theresa Maxino, whose conclusions I found surprising.

It all depends on what your data are like and what
kinds of errors you plausibly need to protect against,

More information about the erlang-questions mailing list