如题.
    生成多项式为:X^16+X^12+X^5+1,高8位在前

解决方案 »

  1.   

    要可以生成crc校验码,可以校验字符串是否crc校验正确
      

  2.   

    var
      Form1: TForm1;
      vCRC16Table: array[Byte] of Word; //CRC16表
    implementation{$R *.dfm}
    function UpdateCRC16( //更新CRC16的值
      mChar: Char; //字符
      mSeed: Word //Seed
    ): Word; //返回更新后的CRC16值
    begin
      result :=
        vCRC16Table[(mSeed and $000000FF) xor Byte(mChar)] xor (mSeed shr 8);
    end; { UpdateCRC16 }function StringCRC16( //取得字符串的CRC16值
      mString: string //字符串
    ): Word; //返回字符串的CRC16值
    var
      I: Integer;
    begin
      result := $FFFF;
      for I := 1 to Length(mString) do result := UpdateCRC16(mString[I], result);
      result := not result;
    end; { StringCRC16 }
      

  3.   

    http://www.efg2.com/Lab/Mathematics/CRC.htm
      

  4.   

    谢谢,请注意:生成多项式为:X^16+X^12+X^5+1,高8位在前
      

  5.   

    哪有这么多现成的东西,
    上面网址里有源代码,包括lookup table的生成算法,
    你应该仔细看看:
    /////////////////////////////////////////////
    For a CRC-16, the lookup table consists of 256 2-byte WORDs (see below, or the CRC16.PAS unit for the actual table, or the CRCTable program for computation of the lookup table for the x16 + x15 + x2 + 1 generator polynomial):
    /////////////////////////////////////////////
    PROGRAM CRCTable;
     {CRCTable generates the table of constants needed for byte-wise CRC-16
      calculations.  The constants are formatted for inclusion in the
      CRC UNIT.  (C) Copyright 1989, Earl F. Glynn, Overland Park, KS.  Compuserve 73257,3527.
      All Rights Reserved.  This Turbo Pascal 5.5 PROGRAM may be freely distributed
      for non-commercial use.  This program was derived from the CRCV FORTRAN 77 program given in
      "Byte-wise CRC Calculations" by Aram Perez in IEEE Micro, June 1983,
      pp. 40-50.  The constants here are for the CRC-16 generator polynomial
      X^16 + X^15 + X^2 + 1.  Other generator polynomials could be used
      but a new derivation would be needed to calculate the 'v' variables
      below.}