Re: Fletcher Checksum Question
From: Benjamin Goldberg (goldbb2@earthlink.net)
Date: 02/04/03
- Next message: Stephen Ymage: "Re: Fletcher Checksum Question"
- Previous message: David Wagner: "Re: Weakness in RSA"
- In reply to: Stephen Ymage: "Fletcher Checksum Question"
- Next in thread: Stephen Ymage: "Re: Fletcher Checksum Question"
- Reply: Stephen Ymage: "Re: Fletcher Checksum Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: Benjamin Goldberg <goldbb2@earthlink.net> Date: Tue, 04 Feb 2003 16:36:51 -0500
Stephen Ymage wrote:
>
> The Fletcher function I have is coded this way (for clarity, some
> lines were left out):
>
> while (n--) {
> s1 = (s1 + *bufp++) & 0x0000ffff;
> s2 = (s2 + s1) & 0x0000ffff;
> }
> return (s2 << 16) + s1;
>
> My question is, why not code it this way:
>
> while (n--) {
> s1 = (s1 + *bufp++) & 0x0000ffff;
> s2 += s1;
> }
> return s2;
The reason not to code it the second way is because it returns a
different result than the first. Now, what you *might* want, due to
it's being faster than either of those two, *and* gives the same results
as the first bit of code, would be this:
while (n--) {
s1 += *bufp++;
s2 += s2;
}
return ((s2 << 16) | (s1 & 0xffff)) & 0xffffFFFF;
> Wont this be just as reliable as far as a check, if not better, and
> faster?
Maybe, maybe not, but your code definitely would be incompatible with
other programs which calculate *real* the fletcher checksum.
> Or, is there something I don't see?
> I realize these values wont match. I don't need to match with other
> Fletcher implementations.
Well, if you don't need that... then what *do* you need?
All checksum functions have their limitations; instead of picking an
existing one, fiddling with it, and asking if it's "better", decide what
requirements you have for your checksum function, and then go and find
one which *has* those requirements. Or if necessary, ask here.
[snip]
> Also, I didn't want this to be a debate of CRC vs. Fletcher vs. Adler
> checksums.
Well, you're already turning it into Fletcher vs
something-based-on-Fletcher-but-which-isn't-really-Fletcher.
Except that you haven't defined what "better" for a checksum means to
you, so we can't really tell you which is "better".
-- "So, who beat the clueless idiot today?" "Well, we flipped for it, but when Kuno landed, he wasn't in any shape to fight." "Next time, try flipping a *coin.*"
- Next message: Stephen Ymage: "Re: Fletcher Checksum Question"
- Previous message: David Wagner: "Re: Weakness in RSA"
- In reply to: Stephen Ymage: "Fletcher Checksum Question"
- Next in thread: Stephen Ymage: "Re: Fletcher Checksum Question"
- Reply: Stephen Ymage: "Re: Fletcher Checksum Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|