CRC checking
tperdue
created: 2004-06-16 10:05:10
I am in need of a way to check a string for the presence of a given CRC-16. Is there any way to easily check for the presence of the CRC? My generating polynomial is x15+x14+x13+x11+x4+x2+x (1110100000010101). I've searched the site and found some things on CRC but not what I'm looking for.
Re: CRC checking
created: 2004-06-16 10:15:58
Check out unpack. I think that's what you're looking for.

Good Luck

Cheers

Sweetblood

Re: CRC checking
created: 2004-06-16 10:16:33

Maybe Digest::CRC is doing what you need?

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus

Re^2: CRC checking
created: 2004-06-16 11:07:02
I haven't checked out digest::crc. I'll have a look at that right now. Thanks.
Re^2: CRC checking
created: 2004-06-17 05:58:26
I had a look at Digest::CRC and believe it will do what I want but documentation is very limited. Can you explain init, xorout, refin and refout? I understand the width and poly fields.
Re^3: CRC checking
created: 2004-06-17 06:20:27

A quick glance at the source suggests that they are flags/values indicating/used for:

  • refin
    reflect bitwise (mirror) the input before processing the message
  • refout
    reflect bitwise (mirror) the processed data before returning (hmmm, unless refin is set...)
  • xorout
    the output is XORed with this value prior to returning it
  • init
    is the initial crc value
Update: (added init explanation) I suggest you take a closer look at the %_typedef hash!

Edit: removed doubt-indicating questionmarks.

HTH, regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus

perlmonks.org content © perlmonks.org and sweetblood, Tomte, tperdue

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03