Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!ucsd!ucsdhub!esosun!seismo!uunet!vsi!friedl
From: friedl@vsi.UUCP (Stephen J. Friedl)
Newsgroups: comp.misc
Subject: Anybody have a checksum algorithm that detects byte-swap?
Message-ID: <735@vsi.UUCP>
Date: 27 Jun 88 13:35:06 GMT
Distribution: comp
Organization: V-Systems, Inc. -- Santa Ana, CA
Lines: 31

Hi,

     I am writing some sort programs on two different machines
and really don't want to move megabyte files around to see if the
output from identically-run programs is the same.  I figure that
I can be moderately safe by using a 32-bit checksum, but the UNIX
sum(1) is inadequate because it appears to be a simple additive
checksum; it won't detect bytes moving around in a file ("abc"
and "cba" both have the same checksum).

     I have a naive algorithm of multiplying the byte just read
with the byte number:

		while (c = getchar(), c != EOF)
			sum += (c * ++count);

     It strikes me that this is an area where a lack of rigor
could be troublesome: Any of you ECC folks got anything better?
I don't mind doing a little bit more work to make it sensitive to
"common" things that can go wrong with a file.  Would a CRC be
overkill?  Any suggestions?

     Please email, I'll summarize, etc.

     Steve

-- 
Steve Friedl     V-Systems, Inc. (714) 545-6442     3B2-kind-of-guy
friedl@vsi.com     {backbones}!vsi.com!friedl    attmail!vsi!friedl

Nancy Reagan on the Free Software Foundation : "Just say GNU"