[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] CRC.pm for Macintosh



You are -so- right. Doh!.

Thanks for putting me straight.

Best wishes,

Lindsay


>>You probably don't need to do this, as you can just use perl's unpack
>>function to generate a CRC. Camel p.237 gives the following example
>>for a 32 bit CRC...
>>
>>	undef $/;
>>	$checksum = unpack("%32C*", <FILEHANDLE>) % 32767;
>
> I think you're confusing a CRC with a plain checksum.
>
> In checksums, the bytes are simply added, and the result is given modulo
> some upper value (only the lower bits preserved). In a CRC, the result
> depends on the order of bytes as well. That's one of the things that
> makes it so powerful!
>
> 	$\ = "\n";
> 	print unpack("%32C*", 'ab') % 32767;
> 	print unpack("%32C*", 'ba') % 32767;
> 	print ord('a') + ord('b');
>
> Result:
>
> 	195
> 	195
> 	195
>
> Yup. A plain checksum, not a CRC.
>
> 	Bart.
>
> ***** Want to unsubscribe from this list?
> ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch