Prev: Re basic to vb
Next: String decoding
From: Tony Toews [MVP] on 22 May 2010 23:56 Folks I've had a request to double check that files which my utility as copied from the network server to the client PC has been copied correctly. Presumably by using a CRC although it looks like I could also use SHA or MD5.. Any comments on Calculating CRC32 With VB http://www.vbaccelerator.com/home/vb/code/libraries/CRC32/article.asp Any better algorithms out there? I'm not at all sure this is required because I would've though Windows networking would double check that the files coming across the network were intact. But then this would be the standard belt and suspenders I guess. Just in case the hard drive is failing or something goofy like that. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/
From: MM on 23 May 2010 05:09 On Sat, 22 May 2010 21:56:19 -0600, "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: >Folks > >I've had a request to double check that files which my utility as >copied from the network server to the client PC has been copied >correctly. Presumably by using a CRC although it looks like I could >also use SHA or MD5.. > >Any comments on Calculating CRC32 With VB >http://www.vbaccelerator.com/home/vb/code/libraries/CRC32/article.asp > >Any better algorithms out there? > >I'm not at all sure this is required because I would've though Windows >networking would double check that the files coming across the network >were intact. But then this would be the standard belt and suspenders >I guess. Just in case the hard drive is failing or something goofy >like that. > >Tony I use the free bincomp.exe. Here's how I call it from my VB6 front-end app: lRet = ExecCmd("c:\utils\bincomp\bincomp " & Chr$(34) & sSourceFile & Chr$(34) & " " & Chr$(34) & sDestinationFile & Chr$(34) & " /Q") Public Function ExecCmd(cmdline$) As Long Dim proc As PROCESS_INFORMATION Dim start As STARTUPINFO Dim ret As Long ' Initialize the STARTUPINFO structure: start.cb = Len(start) start.dwFlags = STARTF_USESHOWWINDOW start.wShowWindow = SW_HIDE ' SW_MINIMIZE ' Start the shelled application: ret = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _ NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc) ' Wait for the shelled application to finish: ret& = WaitForSingleObject(proc.hProcess, INFINITE) Call GetExitCodeProcess(proc.hProcess, ret) Call CloseHandle(proc.hThread) Call CloseHandle(proc.hProcess) ExecCmd = ret End Function Get it here: http://www.softlist.net/company/steven_wettberg.html I haven't updated my version of bincomp for ages, so you may see a much later version on his website. I've used my app to compare all sorts of files, including massive VOBs and large True Image image files. MM
From: Jason Keats on 23 May 2010 06:11 Tony Toews [MVP] wrote: > Folks > > I've had a request to double check that files which my utility as > copied from the network server to the client PC has been copied > correctly. Presumably by using a CRC although it looks like I could > also use SHA or MD5.. > > Any comments on Calculating CRC32 With VB > http://www.vbaccelerator.com/home/vb/code/libraries/CRC32/article.asp > > Any better algorithms out there? > > I'm not at all sure this is required because I would've though Windows > networking would double check that the files coming across the network > were intact. But then this would be the standard belt and suspenders > I guess. Just in case the hard drive is failing or something goofy > like that. > > Tony That seems to be a very fast implementation of CRC32 - at least, it's a lot faster than the one I've been using. :-) I've used the following for SHA1: http://vb.wikia.com/wiki/SHA-1.bas It seems to be faster than the CRC32 implementation you're using, is less likely to produce duplicate values (if that's important) and it's certainly more secure (only important if you're going to use it with passwords, etc.).
From: Jim Mack on 23 May 2010 09:12 Tony Toews [MVP] wrote: > Folks > > I've had a request to double check that files which my utility as > copied from the network server to the client PC has been copied > correctly. Presumably by using a CRC although it looks like I could > also use SHA or MD5.. > > Any comments on Calculating CRC32 With VB > http://www.vbaccelerator.com/home/vb/code/libraries/CRC32/article.asp > > Any better algorithms out there? CRC32 has the benefit of being very fast to calculate, and if you're already reasonably sure that the file is correct -- you've done the obvious, like check byte length -- then CRC32 is probably enough. Even for very long files, the odds of a mis-hit are minuscule. The reason is that it's millions of times more likely to generate a false negative than a false positive. MD5 and the other secure hashes are much better at guaranteeing that a byte sequence is unique, but may be overkill, and they're correspondingly slower. But if you have the time, they're the best you can do. I'd say SHA-256 is the gold standard right now. It's common to pre-compute hashes for all files in a directory and keep them in a separate text file. Then you need to hash only on the target side, and compare to what's already done on the source side. -- Jim Mack Twisted tees at http://www.cafepress.com/2050inc "We sew confusion"
From: Tony Toews [MVP] on 23 May 2010 16:42
"Jim Mack" <jmack(a)mdxi.nospam.com> wrote: >It's common to pre-compute hashes for all files in a directory and >keep them in a separate text file. Then you need to hash only on the >target side, and compare to what's already done on the source side. Yes, that was exactly what I was going to do. Especially given that that "from" file is on a network and usually the "to" file is on a local hard drive. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/ |