tperdue has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: CRC checking
by Tomte (Priest) on Jun 16, 2004 at 14:16 UTC

    Maybe Digest::CRC is doing what you need?

    regards,
    tomte


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

      I haven't checked out digest::crc. I'll have a look at that right now. Thanks.
      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.

        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

Re: CRC checking
by sweetblood (Prior) on Jun 16, 2004 at 14:15 UTC
    Check out unpack. I think that's what you're looking for.

    Good Luck

    Cheers

    Sweetblood