vb.netCRC 컴퓨팅 -----CRCCCITT

    Public Function CRC_CCITT(ByVal Data() As Byte) As String

        Dim crc As UShort
        Dim i As Byte, j As Integer
        Dim crch As String, crcl As String

        crc = 0
        For j = 0 To Data.Length - 1
            i = &H80
            Dim val As UShort = Data(j)
            val = val << 8
            crc = crc Xor val

            While (i <> 0)
                If (crc And &H8000) <> 0 Then
                    crc = crc << 1
                    crc = crc Xor &H1021
                Else
                    crc = crc << 1
                End If
                i = i / 2
            End While
        Next j

        crch = Hex(Fix(crc / 256))
        If Len(crch) = 1 Then crch = "0" & crch
        crcl = Hex(crc Mod 256)
        If Len(crcl) = 1 Then crcl = "0" & crcl
        CRC_CCITT = crch & crcl

    End Function

좋은 웹페이지 즐겨찾기