b1t5tR3@m Posted October 23, 2005 Share Posted October 23, 2005 (edited) Just a small prog for generating checksum's...I used Solidsnake's UDF's for interfacing to the MD5 Deep utilities.@Solidsnake; had to edit one or two of your UDF's because they were cutting off the length of the checksums...specifically SHA256 and Whirlpool (actually I'm not sure you made one for Whirlpool, but there is now). Thanks for the foundation...I double checked the output with another checksum utility named fsum.exe; all is well.Note: the length of the Whirlpool checksum is 128 characters, so if you choose it you'll have to do a 'Ctrl + A' to get all of the output...it's longer than the input box.I would like to incorporate at least SHA-512 at some point, and perhaps the ability to save all generated checksums to a .txt file. I could have saved the included functions as UDF's and just did a #include at the top; wasn't working for some reason so I just included them in body of the script. I'm sure there's lots of things that could have been done differently, so Uber-Coders be nice upon evaluation...You'll need the MD5 Deep Utilities to use this... here.expandcollapse popup;Checksum Generator by MG...thanks to SolidSnake's hash UDF's and the MD5Deep Command Line utilities #Include <GuiConstants.au3> ;==========Local File Installation $destination = @ScriptDir & "\md5deep.exe" FileInstall("C:\Utils\md5deep\md5deep.exe", $destination) $destination = @ScriptDir & "\sha1deep.exe" FileInstall("C:\Utils\md5deep\sha1deep.exe", $destination) $destination = @ScriptDir & "\sha256deep.exe" FileInstall("C:\Utils\md5deep\sha256deep.exe", $destination) $destination = @ScriptDir & "\tigerdeep.exe" FileInstall("C:\Utils\md5deep\tigerdeep.exe", $destination) $destination = @ScriptDir & "\whirlpooldeep.exe" FileInstall("C:\Utils\md5deep\whirlpooldeep.exe", $destination) ;==========GUI Creation If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("File Hash Generator", 553, 251,(@DesktopWidth-553)/2, (@DesktopHeight-251)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Button_0 = GuiCtrlCreateButton("Clear Fields", 10, 210, 90, 20) $Button_1 = GuiCtrlCreateButton("MD5", 10, 50, 90, 20) $Button_2 = GuiCtrlCreateButton("SHA-1", 10, 80, 90, 20) $Button_3 = GuiCtrlCreateButton("SHA-256", 10, 110, 90, 20) $Button_4 = GuiCtrlCreateButton("Tiger Deep", 10, 140, 90, 20) $Button_5 = GuiCtrlCreateButton("Whirlpool Deep", 10, 170, 90, 20) $Button_6 = GuiCtrlCreateButton("Browse", 10, 20, 90, 20) $Input_7 = GuiCtrlCreateInput("", 110, 50, 430, 20) $Input_8 = GuiCtrlCreateInput("", 110, 80, 430, 20) $Input_9 = GuiCtrlCreateInput("", 110, 110, 430, 20) $Input_10 = GuiCtrlCreateInput("", 110, 140, 430, 20) $Input_11 = GuiCtrlCreateInput("", 110, 170, 430, 20) $Input_12 = GuiCtrlCreateInput("", 110, 20, 430, 20) ;==========Code Body GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $Button_6 ;FileOpenDialog ( "Choose a file...", "C:\", "All (*.*)", 1) $file = FileOpenDialog("Choose a file...", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "All Files (*.*)", 1) If @error Then ContinueLoop GUICtrlSetData($input_12, $file) Case $msg = $Button_1 $val = GUICtrlRead($input_12) $md5 = _FileHashMD5($val) GUICtrlSetData($input_7, $md5) Case $msg = $Button_2 $val2 = GUICtrlRead($input_12) $sha = _FileHashSHA1($val2) GUICtrlSetData($input_8, $sha) Case $msg = $Button_3 $val3 = GUICtrlRead($input_12) $sha256 = _FileHashSHA256($val3) GUICtrlSetData($input_9, $sha256) Case $msg = $Button_4 $val4 = GUICtrlRead($input_12) $tiger = _TigerDeep($val4) GUICtrlSetData($input_10, $tiger) Case $msg = $Button_5 $val5 = GUICtrlRead($input_12) $whirl = _Whirlpool($val5) GUICtrlSetData($input_11, $whirl) Case $msg = $Button_0 GUICtrlSetData($Input_7, "") GUICtrlSetData($Input_8, "") GUICtrlSetData($Input_9, "") GUICtrlSetData($Input_10, "") GUICtrlSetData($Input_11, "") GUICtrlSetData($Input_12, "") Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit ;==========MD5 Function Func _FileHashMD5($sFile, $iRunErrorsFatal = -1, $vEXEPath = 0) Local $sEXEPath, $hPID, $sLine, $iFileNameLen, $sHash, $iOPT If Not FileExists($sFile) or StringInStr(FileGetAttrib($sFile),"D") or StringInStr($sFile,"?") or StringInStr($sFile,"?") or Not StringInStr($sFile,"\") Then SetError(1) Return "" EndIf If Not ($iRunErrorsFatal = 0 Or $iRunErrorsFatal = 1 Or $iRunErrorsFatal = -1) Then SetError(2) Return "" EndIf If $vEXEPath = 0 Then $sEXEPath = @ScriptDir & "\md5deep.exe" Else $sEXEPath = $vEXEPath EndIf If $iRunErrorsFatal <> - 1 Then $iOPT = opt("RunErrorsFatal", $iRunErrorsFatal) $hPID = Run('"' & $sEXEPath & '" "' & $sFile & '"', @SystemDir, @SW_HIDE, 6) If @error Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(3) Return "" EndIf ProcessWaitClose($hPID) $sLine = StdoutRead ($hPID) $iFileNameLen = StringLen($sFile) $sLine = StringTrimRight($sLine, 2) If Not StringLen($sLine) = 33 + $iFileNameLen Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf If StringRight($sLine, $iFileNameLen) <> $sFile Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf $sHash = StringLeft($sLine, 32) If Not StringIsXDigit($sHash) Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash SetError(4) Return "" EndIf If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash EndFunc ;==>_FileHashMD5 ;==========SHA1 Function Func _FileHashSHA1($sFile, $iRunErrorsFatal = -1, $vEXEPath = 0) Local $sEXEPath, $hPID, $sLine, $iFileNameLen, $sHash, $iOPT If Not FileExists($sFile) or StringInStr(FileGetAttrib($sFile),"D") or StringInStr($sFile,"?") or StringInStr($sFile,"?") or Not StringInStr($sFile,"\") Then SetError(1) Return "" EndIf If Not ($iRunErrorsFatal = 0 Or $iRunErrorsFatal = 1 Or $iRunErrorsFatal = -1) Then SetError(2) Return "" EndIf If $vEXEPath = 0 Then $sEXEPath = @ScriptDir & "\sha1deep.exe" Else $sEXEPath = $vEXEPath EndIf If $iRunErrorsFatal <> - 1 Then $iOPT = opt("RunErrorsFatal", $iRunErrorsFatal) $hPID = Run('"' & $sEXEPath & '" "' & $sFile & '"', @SystemDir, @SW_HIDE, 6) If @error Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(3) Return "" EndIf ProcessWaitClose($hPID) $sLine = StdoutRead ($hPID) $iFileNameLen = StringLen($sFile) $sLine = StringTrimRight($sLine, 2) If Not StringLen($sLine) = 41 + $iFileNameLen Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf If StringRight($sLine, $iFileNameLen) <> $sFile Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf $sHash = StringLeft($sLine, 40) If Not StringIsXDigit($sHash) Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash SetError(4) Return "" EndIf If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash EndFunc ;==>_FileHashSHA1 ;==========SHA256 Function Func _FileHashSHA256($sFile, $iRunErrorsFatal = -1, $vEXEPath = 0) Local $sEXEPath, $hPID, $sLine, $iFileNameLen, $sHash, $iOPT If Not FileExists($sFile) or StringInStr(FileGetAttrib($sFile),"D") or StringInStr($sFile,"?") or StringInStr($sFile,"?") or Not StringInStr($sFile,"\") Then SetError(1) Return "" EndIf If Not ($iRunErrorsFatal = 0 Or $iRunErrorsFatal = 1 Or $iRunErrorsFatal = -1) Then SetError(2) Return "" EndIf If $vEXEPath = 0 Then $sEXEPath = @ScriptDir & "\sha256deep.exe" Else $sEXEPath = $vEXEPath EndIf If $iRunErrorsFatal <> - 1 Then $iOPT = opt("RunErrorsFatal", $iRunErrorsFatal) $hPID = Run('"' & $sEXEPath & '" "' & $sFile & '"', @SystemDir, @SW_HIDE, 6) If @error Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(3) Return "" EndIf ProcessWaitClose($hPID) $sLine = StdoutRead ($hPID) $iFileNameLen = StringLen($sFile) $sLine = StringTrimRight($sLine, 2) If Not StringLen($sLine) = 65 + $iFileNameLen Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf If StringRight($sLine, $iFileNameLen) <> $sFile Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf $sHash = StringLeft($sLine, 64) If Not StringIsXDigit($sHash) Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash SetError(4) Return "" EndIf If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash EndFunc ;==>_FileHashSHA256 ;==========TigerDeep Function Func _TigerDeep($sFile, $iRunErrorsFatal = -1, $vEXEPath = 0) Local $sEXEPath, $hPID, $sLine, $iFileNameLen, $sHash, $iOPT If Not FileExists($sFile) or StringInStr(FileGetAttrib($sFile),"D") or StringInStr($sFile,"?") or StringInStr($sFile,"?") or Not StringInStr($sFile,"\") Then SetError(1) Return "" EndIf If Not ($iRunErrorsFatal = 0 Or $iRunErrorsFatal = 1 Or $iRunErrorsFatal = -1) Then SetError(2) Return "" EndIf If $vEXEPath = 0 Then $sEXEPath = @ScriptDir & "\tigerdeep.exe" Else $sEXEPath = $vEXEPath EndIf If $iRunErrorsFatal <> - 1 Then $iOPT = opt("RunErrorsFatal", $iRunErrorsFatal) $hPID = Run('"' & $sEXEPath & '" "' & $sFile & '"', @SystemDir, @SW_HIDE, 6) If @error Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(3) Return "" EndIf ProcessWaitClose($hPID) $sLine = StdoutRead ($hPID) $iFileNameLen = StringLen($sFile) $sLine = StringTrimRight($sLine, 2) If Not StringLen($sLine) = 49 + $iFileNameLen Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf If StringRight($sLine, $iFileNameLen) <> $sFile Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf $sHash = StringLeft($sLine, 48) If Not StringIsXDigit($sHash) Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash SetError(4) Return "" EndIf If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash EndFunc ;==>_TigerDeep ;==========WhirlpoolDeep Function Func _Whirlpool($sFile, $iRunErrorsFatal = -1, $vEXEPath = 0) Local $sEXEPath, $hPID, $sLine, $iFileNameLen, $sHash, $iOPT If Not FileExists($sFile) or StringInStr(FileGetAttrib($sFile),"D") or StringInStr($sFile,"?") or StringInStr($sFile,"?") or Not StringInStr($sFile,"\") Then SetError(1) Return "" EndIf If Not ($iRunErrorsFatal = 0 Or $iRunErrorsFatal = 1 Or $iRunErrorsFatal = -1) Then SetError(2) Return "" EndIf If $vEXEPath = 0 Then $sEXEPath = @ScriptDir & "\whirlpooldeep.exe" Else $sEXEPath = $vEXEPath EndIf If $iRunErrorsFatal <> - 1 Then $iOPT = opt("RunErrorsFatal", $iRunErrorsFatal) $hPID = Run('"' & $sEXEPath & '" "' & $sFile & '"', @SystemDir, @SW_HIDE, 6) If @error Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(3) Return "" EndIf ProcessWaitClose($hPID) $sLine = StdoutRead ($hPID) $iFileNameLen = StringLen($sFile) $sLine = StringTrimRight($sLine, 2) If Not StringLen($sLine) = 129 + $iFileNameLen Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf If StringRight($sLine, $iFileNameLen) <> $sFile Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(4) Return "" EndIf $sHash = StringLeft($sLine, 128) If Not StringIsXDigit($sHash) Then If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash SetError(4) Return "" EndIf If $iRunErrorsFatal <> - 1 Then opt("RunErrorsFatal", $iOPT) SetError(0) Return $sHash EndFunc ;==>_Whirlpool ;==========Program Termination Func OnAutoItExit() FileDelete(@ScriptDir & "\md5deep.exe") FileDelete(@ScriptDir & "\sha1deep.exe") FileDelete(@ScriptDir & "\sha256deep.exe") FileDelete(@ScriptDir & "\tigerdeep.exe") FileDelete(@ScriptDir & "\whirlpooldeep.exe") EndFunc ExitEnjoy:: Edited October 23, 2005 by b1t5tR3@m Link to comment Share on other sites More sharing options...
FuryCell Posted October 23, 2005 Share Posted October 23, 2005 Cool. The WhirlPool and Tiger funcs were not made by me but modified from my funcs. P.S. Thanks for finding the bug in _FileHashSHA256(). Will fix it soon. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
b1t5tR3@m Posted October 23, 2005 Author Share Posted October 23, 2005 The WhirlPool and Tiger funcs were not made by me but modified from my funcs.Right......thought I made it sorta clear: "actually I'm not sure you made one for Whirlpool, but there is now". The Tiger (and Whirlpool) one was based off your other UDF's with changes made to reflect 1) the program, and 2) the hash length. Sorry if I didn't make that clear enough.Anyway.....you did all the REAL work. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now