[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CRC16 ccitt 1021 - Part 1
- From: Francisco Olarte <folarte@...>
- Date: Thu, 24 Oct 2019 09:59:03 +0200
Russell:
On Thu, Oct 24, 2019 at 5:44 AM Russell Haley <russ.haley@gmail.com> wrote:
> function ccitt_16(byte_array)
Your bit32 functions have already been answered, I'd just like to
point yuou that, if you need CRC, nobody calculates it bit-by-bit.
There are ways to do it N bits at a time with the aid of a 2^n entries
lookup table ( wikipedia and other sources explain the math behind
this and there are plenty of implementations floating around ),
typically with N=8, a byte at a time, as this avoids all the
complexity of bit-extracting ( I've done ccitt 16 it this way, and
besides being much simpler and faster part of the space for the 256
entries tables is offset by the lack of bit-twiddling code, so it ends
up not that much bigger, but this was in C where the table is 512
bytes, not lua where the straight table approach ( you can use a 512
bytes string instead ) is much biger ).
Francisco Olarte.