Sign in to follow this  
Followers 0
storme

Need faster alternative to _Crypt_HashFile

6 posts in this topic

I've written a script to copy an important backup from the main hard drive to a USB hard drive.

Because the file is so important I decided to do a _Crypt_HashFile of the main file then compare it to the version copied to the usb drive.

Func FileCopyAndCheck($fileName, $source, $destination, $flag = 0)
    ;Success =
    ; Failure   @error = 1 ; Copy failed
    ;           @error = 2 ; Copy worked but files are different
    LogState($hLogFile, "Copy From:" & $source & "\" & $fileName & " To:" & $destination)
    If FileCopy($source & "\" & $fileName, $destination, $flag) = 0 Then
        LogState($hLogFile, "ERROR: Unalbe to copy file From:" & $source & " To:" & $destination)
        Return SetError(1, 0, "Copy Failed")
    ElseIf _Crypt_HashFile($source & "\" & $fileName, $CALG_SHA1) <> _Crypt_HashFile($destination & "\" & $fileName, $CALG_SHA1) Then
        LogState($hLogFile, "ERROR: Unalbe to copy file From:" & $source & " To:" & $destination)
        Return SetError(2, 0, "Failed compare")
    EndIf
    Return 1 ; OK
EndFunc   ;==>FileCopyAndCheck

Worked perfectly on the trial files...BUT... the backup file is 23GB (YEP LARGE FILE) and it takes forever to do the hash.

Any suggestions on how to ckeck if the file was copied perfectly without wating for "ages"

Thanks for any help!

John Morrison

aka

Storm-E

Share this post


Link to post
Share on other sites



hi John,

Maybe will be faster, why not give it a shot. Do post the results if you do :unsure:

Really hope this helps :>

-smartee

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yep. Do the scanning in low propriety in the background, and make it popup a reminder when its done. Ergo: No need to wait for it.

Unless you got some data/facts suggesting its doing it relative slower than general normal sized files ... you just got a reality reminder. Big files take longer! ... hehe.

--- --- ---

Oh yea, Yep, Or use faster code of course. :unsure:

relative data in case you drop some stats.

- time to copy file on USB drive. (or read it from USB if that's faster)

- time to do the scan of the same file. (old way and new way)

Edited by singularity

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Yep. Do the scanning in low propriety in the background, and make it popup a reminder when its done. Ergo: No need to wait for it.

Good idea but this is a scheduled batch task that runs a 4am every morning.

The time probably isn't going to worry any one as it should be finished by the time they get in at 8am. BUT I’d prefer it to be finished long before they get in.

Unless you got some data/facts suggesting its doing it relative slower than general normal sized files ... you just got a reality reminder. Big files take longer! ... hehe.

I didn't realise their backup file had got so big.

Initially I thought my script had crashed as it doesn't give any feedback (no user watching it) except to a log file.

Oh yea, Yep, Or use faster code of course. :unsure:

relative data in case you drop some stats.

- time to copy file on USB drive. (or read it from USB if that's faster)

- time to do the scan of the same file. (old way and new way)

Can't give you any of that that computer isn't here and I didn't have a drive big enough to take the file with me.

It's even going to be difficult here as I don’t have that large a USB drive to test with. :>

I was hoping someone had an alternative that would speed things up.

I'm even contemplating using the dos copy command with a /V to do the copy and verify. Just have to find out how to capture the return code.

Thanks for the help!

Share this post


Link to post
Share on other sites

Hashing requires reading of the whole file, so you can remove the hashing and just compare the two files directly. This could be faster.


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

I know must likely you want to use autoit and this is out of the subject, but a large file like that I will use rsync for windows.


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0