Results 1 to 3 of 3

Thread: (Pardon the ignorance) CRC

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258

    Post

    Hey ,

    Well What I'm trying to figure out is how to the crc value of a string . As for the ignorance , If I knew exactly what crc was I might have been able to do it along . I know I want it for file transfer .

    Thanks

    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Cyclic Redundancy Check

    It is a way of using bit values to ensure that the string transmitted is what is received. If individual bits are transposed in transmission the CRC will reveal this. I believe that ther are several schemes but I don't know the implementation details. I could find them out tho' if it is important.

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Guest
    Code:
    Public Function CalcChecksum(S As String) As Byte
    ' =====================================================================================
    ' ===                                                    Comments by CommentMaker   ===
    ' =====================================================================================
    '
    ' Function    : CalcChecksum
    ' Date/Time   : wednesday 20-sep-2000 / 09:45
    ' By          : Rob Janssen
    '
    ' Versie      : 1.0
    '
    ' Description:
    '
    ' Calculates a string-checksum (CRC):
    '
    ' 1) Put 1st byte of the string in a Checksum-byte
    ' 2) Clear bit 7 of the resultaat
    ' 3) Set bit 6 of the resultaat
    ' 4) Add the result to the next byte (=char) of the string
    ' 5) Repeat steps 2-4 till the end of the string
    '
    '
    ' Parameters  :
    '
    '   S                   - [Required] String          "To-be-checksummed"-string
    '
    ' Return      : Byte
    '
    ' Revisions   :
    '
    ' =====================================================================================
    ' ===                                                    Comments by CommentMaker   ===
    ' =====================================================================================
        
        Dim chk As Byte ' Checksum
        Dim T As Long   ' Char-pointer...
        
        ' Step 1
        chk = Asc(Mid(S, 1, 2))    ' Get 1st Char
        
        T = 1
        While T < Len(S)
           
            ' Step 2
            chk = chk And 127   ' Bitwise operation. Clear bit 7 (127 -> 01111111)
            
            ' Step 3
            chk = chk Or 64     ' Bitwise operation. Set bit 6 (64 -> 01000000)
            
            T = T + 1
            
            ' Step 4
            chk = Asc(Mid(S, T, 1)) + chk
        Wend
        
        CalcChecksum = chk
    End Function
    usage:

    Code:
       Dim CRC as Byte
       
       CRC=CalcChecksum("Hello World")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width