有没有类似我所提供的VB代码的CRC代码,请提供一下,谢谢Function CRC8(ByRef Data() As Byte, beg As Byte, zijie As Byte, ByRef YanzhengMa() As Byte, shi As Byte) As Boolean
  Dim CRC16Lo As Byte, CRC16Hi As Byte      'CRC寄存器
  Dim CL As Byte, ch As Byte                '多项式码&HA001
  Dim SaveHi As Byte, SaveLo As Byte
  Dim i As Byte
  Dim flag As Integer
  CRC8 = False
  
  CRC16Lo = &H0
  CL = &H8C
  For i = beg To beg + zijie - 1
    CRC16Lo = CRC16Lo Xor Data(i) '每一个数据与CRC寄存器进行异或
    For flag = 0 To 7
      SaveLo = CRC16Lo
      CRC16Lo = CRC16Lo \ 2            '低位右移一位
      If ((SaveLo And &H1) = &H1) Then '如果LSB为1,则与多项式码进行异或
          CRC16Lo = CRC16Lo Xor CL
      End If
    Next flag
  Next i
  
  YanzhengMa(shi) = CRC16Lo
  CRC8 = True
End Function

解决方案 »

  1.   

    看一下这个是不是你需要的 http://www.tansoo.cn/?tag=crc
      

  2.   

    unit unCRC16;interfacefunction CalCRC16(AData:array of Byte; AStart,AEnd:Integer): Word;implementationfunction CalCRC16(AData:array of Byte; AStart,AEnd:Integer): Word;
    const
      GENP = $A001;
      
    var
      crc:Word;
      i:Integer;
      tmp:Byte;
      
    procedure CalOneByte(AByte:Byte);
    var
      j:Integer;
    begin
      crc:=crc xor AByte;
      for j := 0 to 7 do
      begin
        tmp:=crc and 1;
        crc:=crc shr 1;
        crc:= crc and $7FFF;
        if tmp = 1 then
          crc:= crc xor GENP;
        crc:=crc and $FFFF;
      end;  
    end;begin
      crc:=$FFFF;
      for i := AStart to AEnd do
        CalOneByte(AData[i]);
      Result:=crc;
    end;  end.