CRC32
-
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
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.
-
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.
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
-
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
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
-
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
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
-
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
can u plz. tell me wots CRC32 rIsHaBh
-
can u plz. tell me wots CRC32 rIsHaBh
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
-
can u plz. tell me wots CRC32 rIsHaBh
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.
-
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.
Thank u buddies!! rIsHaBh
-
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
-
I'm still having huge problems using the dir function. Is there a sample of code i could get
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