Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. CRC32

CRC32

Scheduled Pinned Locked Moved Visual Basic
help
12 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dave Kreskowiak

    You might want to show the code your using to get a CRC on a directory and its contents. Are you looking to get the CRC on all the filenames? Or are you trying to get a combined CRC of all the files in the directory? RageInTheMachine9532

    J Offline
    J Offline
    johnjsm
    wrote on last edited by
    #3

    I am trying to get a combined CRC for all the files. I am using the FastCRC library to try get the code to work. So far I can get the crc of a single file I have tried to code it to check the directory but it never works so I usually start from scratch again.

    D 1 Reply Last reply
    0
    • J johnjsm

      I am trying to get a combined CRC for all the files. I am using the FastCRC library to try get the code to work. So far I can get the crc of a single file I have tried to code it to check the directory but it never works so I usually start from scratch again.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #4

      Code samples are important so we can see what your doing! Your going to have to get the CRC of each file, one at a time. I downloaded the FastCRC library and according to the docs your can use FCRC32_CalculateFile to get the CRC of each file. This is a little pseudocode to illustrate:

      ' Assuming VB.NET
      Dim checksum as Integer
       
      FCRC32_Init()
       
      For Each Filename in Directory
      FCRC32_CalculateFile( checksum, Filename )
      Next
       
      MsgBox( FCRC32_LongToHex32( checksum, True ) )

      RageInTheMachine9532

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Code samples are important so we can see what your doing! Your going to have to get the CRC of each file, one at a time. I downloaded the FastCRC library and according to the docs your can use FCRC32_CalculateFile to get the CRC of each file. This is a little pseudocode to illustrate:

        ' Assuming VB.NET
        Dim checksum as Integer
         
        FCRC32_Init()
         
        For Each Filename in Directory
        FCRC32_CalculateFile( checksum, Filename )
        Next
         
        MsgBox( FCRC32_LongToHex32( checksum, True ) )

        RageInTheMachine9532

        J Offline
        J Offline
        johnjsm
        wrote on last edited by
        #5

        This is the main code that I was using Private Sub cmdCRC32_click() Dim checksum As Long Dim buffer As Long If txtFileInfo.Text = "" Then MsgBox "PLEASE SELECT A FILE", vbExclamation, "No File Selected" End If 'Calculate the CRC32 checksum and MD5 of a file If FCRC32_CalculateFile(checksum, txtFileInfo.Text) = 0 Then txtInfo.Text = txtFileInfo.Text & vbCrLf & _ "CRC32= " & FCRC_LongToHex32(checksum, True) & vbCrLf & _ "MD5=" & QHASH_FileHexDigest(MD5_ALGID, txtFileInfo.Text, True) End If End Sub Thanks

        D 1 Reply Last reply
        0
        • J johnjsm

          This is the main code that I was using Private Sub cmdCRC32_click() Dim checksum As Long Dim buffer As Long If txtFileInfo.Text = "" Then MsgBox "PLEASE SELECT A FILE", vbExclamation, "No File Selected" End If 'Calculate the CRC32 checksum and MD5 of a file If FCRC32_CalculateFile(checksum, txtFileInfo.Text) = 0 Then txtInfo.Text = txtFileInfo.Text & vbCrLf & _ "CRC32= " & FCRC_LongToHex32(checksum, True) & vbCrLf & _ "MD5=" & QHASH_FileHexDigest(MD5_ALGID, txtFileInfo.Text, True) End If End Sub Thanks

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #6

          So far, it looks good, though you can drop the declaration for 'buffer'. You'll never use it... Now all you need to is to wrap this in code that goes thru a list of filenames and your all set. You can use the Dir() function to do this:

          ' Assuming VB.NET
          ' For VB6, change Integer type to Long
          Dim iCheckSum As Integer
          Dim strFilename As String
           
          FCRC32_Init()
          strFilename = Dir( startingPathAsString )
          Do While strFilename <> ""
          FCRC32_CalculateFile( iCheckSum, Filename )
          strFilename = Dir()
          Loop
           
          MsgBox( "CRC32: " & FCRC32_LongToHex32( iCheckSum, True ) )

          RageInTheMachine9532

          J 1 Reply Last reply
          0
          • J johnjsm

            Hi All I have started writing a program to get the crc32 of a file. I have this working fairly well. The only thing now is I need to get the crc32 of a complete folder and its contents and get an overall checksum for it, but I don't seem to be able to get it to work. If anyone can give some insight to this problem it would be great. Also I cannot get to display the file size of the file i am checking. Thanks

            R Offline
            R Offline
            r i s h a b h s
            wrote on last edited by
            #7

            can u plz. tell me wots CRC32 rIsHaBh

            D J 2 Replies Last reply
            0
            • R r i s h a b h s

              can u plz. tell me wots CRC32 rIsHaBh

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #8

              It's a 32 bit Cyclic Redundancy Check. Its used to give a block of data a value that represent an error check. The block of data is transmitted with it's CRC value, then the receiver gets the block, performs a CRC calculation on it and compares that value with the CRC that was transmitted with the block of data. If the two don't match, there was problem with the transmission. RageInTheMachine9532

              1 Reply Last reply
              0
              • R r i s h a b h s

                can u plz. tell me wots CRC32 rIsHaBh

                J Offline
                J Offline
                johnjsm
                wrote on last edited by
                #9

                CRC stands for Cyclic Redundency Check. Where I work we use it to check .iso files transfered over the network to make sure that it is the same. If anything happened to it in transfer there would be a difference. So if the CRC32 is the same then the file is the same. It can be used to check all the files on a cd also, so if any file changed in creating a cd the CRC32 checksum would be different than that of the master disc.

                R 1 Reply Last reply
                0
                • J johnjsm

                  CRC stands for Cyclic Redundency Check. Where I work we use it to check .iso files transfered over the network to make sure that it is the same. If anything happened to it in transfer there would be a difference. So if the CRC32 is the same then the file is the same. It can be used to check all the files on a cd also, so if any file changed in creating a cd the CRC32 checksum would be different than that of the master disc.

                  R Offline
                  R Offline
                  r i s h a b h s
                  wrote on last edited by
                  #10

                  Thank u buddies!! rIsHaBh

                  1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    So far, it looks good, though you can drop the declaration for 'buffer'. You'll never use it... Now all you need to is to wrap this in code that goes thru a list of filenames and your all set. You can use the Dir() function to do this:

                    ' Assuming VB.NET
                    ' For VB6, change Integer type to Long
                    Dim iCheckSum As Integer
                    Dim strFilename As String
                     
                    FCRC32_Init()
                    strFilename = Dir( startingPathAsString )
                    Do While strFilename <> ""
                    FCRC32_CalculateFile( iCheckSum, Filename )
                    strFilename = Dir()
                    Loop
                     
                    MsgBox( "CRC32: " & FCRC32_LongToHex32( iCheckSum, True ) )

                    RageInTheMachine9532

                    J Offline
                    J Offline
                    johnjsm
                    wrote on last edited by
                    #11

                    I'm still having huge problems using the dir function. Is there a sample of code i could get

                    D 1 Reply Last reply
                    0
                    • J johnjsm

                      I'm still having huge problems using the dir function. Is there a sample of code i could get

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #12

                      You'll have to post what you have so we can see what your doing. The only code example I have is in my previous post. RageInTheMachine9532

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups