AIG Posted June 8, 2023 Share Posted June 8, 2023 (edited) Hello everyone, As you probably guessed from the topic title, I'm dealing with multithreading. I know that the AutoIt language does not support multithreading, but I hope someone can suggest an alternative solution. I took an example from the help file for the _Crypt_HashFile function and made some modifications. I added the ability to drag and drop files directly into the program window from the Windows Explorer, and I also wanted to eliminate the need to press a button to start the hashing process. For this purpose, I added the WM_COMMAND function to handle real-time interface messages, so that the program instantly responds to the selection of the algorithm in the ComboBox element and the input of the file name in the Input field. Everything worked out, and it's functioning, but there's a catch. It works well with small-sized files, but if a large file is selected, for example, 800MB, the program window hangs for a while, becomes unresponsive, and displays a "Not Responding" message near the window title. After some time, the window unfreezes and displays the hash result. As far as I understand, this is because the hashing process occurs in the main execution thread of the program and thus slows it down until the hashing process is completed. Does anyone know how to bypass this problem? I tried to extract the code segment responsible for the hashing execution from the WM_COMMAND function, define it as a separate function in a different file, then include the file as a library and call it, but it didn't help. According to this, I decided to keep the original version of the code. Here's the code I ended up with: expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) EndSwitch WEnd ;~ GUIDelete($hGUI) EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam _Crypt_Startup() Local $dHash = 0 Local $sFile = "" Switch _WinAPI_LoWord($wParam) Case $idCombo, $idInput Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch Switch _WinAPI_HiWord($wParam) Case $CBN_SELCHANGE, $EN_CHANGE $sFile = GUICtrlRead($idInput) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf EndSwitch EndSwitch _Crypt_Shutdown() EndFunc Thank you in advance for your assistance! Edited June 8, 2023 by AIG Link to comment Share on other sites More sharing options...
abberration Posted June 8, 2023 Share Posted June 8, 2023 (edited) I made some modifications that eliminate the WM_Command. I tried this code with a 3.3 GB file. It took about 10 seconds to hash, but the gui did not lock up. expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) _Hash($sFile) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput) _Hash($sFileName) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc Edited June 8, 2023 by abberration Fixed a little error. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
AIG Posted June 8, 2023 Author Share Posted June 8, 2023 (edited) 33 minutes ago, abberration said: I made some modifications that eliminate the WM_Command Thank you for trying to help. The solution you suggested actually works with large files, but unfortunately, it loses the ability to automatically perform file hashing after changing the hashing algorithm in the ComboBox element or hash the file immediately after entering the file path in the Input field. Your solution implies using an additional button to initiate the file hashing process. I would like to refrain from using such a button I have been searching for information on solving a similar problem, but unfortunately, I haven't found any. Edited June 8, 2023 by AIG Link to comment Share on other sites More sharing options...
abberration Posted June 8, 2023 Share Posted June 8, 2023 I overlooked that. Simple fix. expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) _Hash($sFile) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput) _Hash($sFileName) Case $idCombo $sFileName = GUICtrlRead($idInput) _Hash($sFileName) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
abberration Posted June 8, 2023 Share Posted June 8, 2023 And out of curiosity if I can do it, I'm trying to get a progressbar working. I think I'm close, but no luck so far. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
abberration Posted June 9, 2023 Share Posted June 9, 2023 (edited) If you are interested in the progressbar version, I got it working. When something is changed (the combo or a new file put in), I made it clear out the old data so you won't glance at it and think it's done. expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GuiEdit.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_PRIMARYDOWN _GUICtrlEdit_SetSel($idInput, 0, -1) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFileName, $Progress1) Case $idCombo $sFileName = GUICtrlRead($idInput) GUICtrlSetData($g_idOutputEdit, "") _Hash($sFileName, $Progress1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile Edit: added code to prevent dragging a new file into the input box and concatenating them instead of overwriting the last file location. Edited June 9, 2023 by abberration AIG 1 Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
argumentum Posted June 9, 2023 Share Posted June 9, 2023 ..you can always fork. look in my signature. AIG 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
AIG Posted June 9, 2023 Author Share Posted June 9, 2023 (edited) 12 hours ago, abberration said: Simple fix. That was the first thing I tried to do in order to make the elements in the GUI window initiate the file hashing process when one of the interface elements was engaged or modified. However, I couldn't make the Input element trigger the file hashing process while entering the file name in the Input field from the keyboard or by copying the file name into the Input element from the clipboard. And I was interested in making it work. If we make the following changes: Spoiler expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 95, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) _Hash($sFile) Case $GUI_EVENT_DROPPED $sFileName = GUICtrlRead($idInput) _Hash($sFileName) Case $idCombo $sFileName = GUICtrlRead($idInput) _Hash($sFileName) Case $idInput $sFileName = GUICtrlRead($idInput) _Hash($sFileName) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile) Local $dHash = 0 _Crypt_Startup() Switch GUICtrlRead($idCombo) Case "MD2 (128bit)" $hashAlgo = $CALG_MD2 Case "MD4 (128bit)" $hashAlgo = $CALG_MD4 Case "MD5 (128bit)" $hashAlgo = $CALG_MD5 Case "SHA1 (160bit)" $hashAlgo = $CALG_SHA1 Case "SHA_256 (256bit)" $hashAlgo = $CALG_SHA_256 Case "SHA_384 (384bit)" $hashAlgo = $CALG_SHA_384 Case "SHA_512 (512bit)" $hashAlgo = $CALG_SHA_512 EndSwitch If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else $dHash = _Crypt_HashFile($sFile, $hashAlgo) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) EndIf _Crypt_Shutdown() EndFunc In this example, if we type or paste the file path into the Input field, the program won't initiate the file hashing process until we use the ComboBox element. Additionally, in this case, the hashing process will start if we change the focus of the active window, meaning we click the mouse somewhere outside the program window with hashing. I understood that the Input element doesn't have the capability to actively respond to changes within itself. That's why since I couldn't make the Input element work the way I needed, I decided to use message registration through the WM_COMMAND function. 11 hours ago, abberration said: If you are interested in the progressbar version, I got it working. That's a great solution, and I will definitely keep it and use it. Thank you Edited June 9, 2023 by AIG Link to comment Share on other sites More sharing options...
abberration Posted June 10, 2023 Share Posted June 10, 2023 I made some modifications. For one, I used GUISetAccelerators to make the Enter key activate the hashing process if you paste or type the file location into the input box. Second, I noticed that dropping a file, the combo and a new method I added all did the same things, so I combined them into one Case. Third, to save space, I converted your selector of the the algorithms into an array. Lastly, and in most importantly, I added a tooltip to show the whole output when you hover over the output. Being in a disabled state, you cannot scroll the text to see the whole string, so if it is too big for the box (and many are), then the what you see is useless. I also added an option to put the results in the clipboard. If you want to enable it, just delete the semicolon. I hope these examples give you some ideas on how you can get things done in AutoIt. expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Array.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, $WS_EX_ACCEPTFILES) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) GUICtrlSetState (-1, $GUI_DROPACCEPTED) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) GUISetState(@SW_SHOW, $hGUI) $idDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $idDummy]] GUISetAccelerators($aAccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_DROPPED, $idCombo, $idDummy $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFileName, $Progress1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else Local $dHash = 0 _Crypt_Startup() Local $aCrypt[8][2] = [["MD2 (128bit)", $CALG_MD2],["MD4 (128bit)", $CALG_MD4],["MD5 (128bit)",$CALG_MD5],["SHA1 (160bit)",$CALG_SHA1],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_384 (384bit)",$CALG_SHA_384],["SHA_512 (512bit)",$CALG_SHA_512]] $hashSelect = GUICtrlRead($idCombo) $hashLoc = _ArraySearch($aCrypt, $hashSelect) $hashAlgo = $aCrypt[$hashLoc][1] $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) GUICtrlSetTip($g_idOutputEdit, $hexHash) ;ClipPut($hexHash) ; copies hash value to clipboard _Crypt_Shutdown() EndIf EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile AIG 1 Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
AIG Posted June 10, 2023 Author Share Posted June 10, 2023 (edited) 17 hours ago, abberration said: I made some modifications. Thank you Abberration, for your responsiveness and the time you've dedicated. Regarding the display of the final result, I initially wanted to use an Edit element with scrolling, so I didn't consider tooltips. However, the way you implemented it is probably even better. Sometimes, when hashing a large file, it may be necessary to cancel the hashing operation while it's still running. So I thought it would be nice to have the ability to stop the hashing process without waiting for it to complete. I thought about using a While loop and a separate variable with True and False parameters to achieve this. Then it would be possible to interrupt the file hashing process with a separate button, and as an alternative, using a ComboBox element to restart hashing process.This would be convenient if we open a large file in the program but forget to select the desired hashing algorithm beforehand. By selecting the algorithm from the ComboBox element or pressing the "Stop" button, we could stop the hashing process or restart it again. I tried to implement this, but my knowledge is very limited, so the script didn't work It seems to me that this approach might not work due to multi-threading expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Array.au3> #include <GuiEdit.au3> Global $idInput, $g_idOutputEdit, $idStopHashButton, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI Global $fKillHash = True Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) $DropLabel = GUICtrlCreateLabel("", 0, 0, 400, 105) GUICtrlSetState(-1, $GUI_DISABLE + $GUI_DROPACCEPTED) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) $idStopHashButton = GUICtrlCreateButton("Stop", 320, 80, 70, 20) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW, $hGUI) $idDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $idDummy]] GUISetAccelerators($aAccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton WinSetOnTop($hGUI, "", 0) Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase WinSetOnTop($hGUI, "", 1) GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") GUICtrlSetState($idStopHashButton, $GUI_ENABLE) $fKillHash = True _Hash($sFile, $Progress1) Case $GUI_EVENT_DROPPED If @GUI_DropId = $DropLabel Then GUICtrlSetData($idInput, @GUI_DragFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") GUICtrlSetState($idStopHashButton, $GUI_ENABLE) $fKillHash = True _Hash(@GUI_DragFile, $Progress1) EndIf Case $idCombo, $idDummy $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") GUICtrlSetState($idStopHashButton, $GUI_ENABLE) $fKillHash = True _Hash($sFileName, $Progress1) Case $idStopHashButton $fKillHash = False GUICtrlSetData($Progress1, 0) GUICtrlSetState($idStopHashButton, $GUI_DISABLE) Case $GUI_EVENT_PRIMARYDOWN _GUICtrlEdit_SetSel($idInput, 0, -1) _GUICtrlEdit_SetSel($g_idOutputEdit, 0, -1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else Local $dHash = 0 _Crypt_Startup() Local $aCrypt[8][2] = [["MD2 (128bit)", $CALG_MD2], ["MD4 (128bit)", $CALG_MD4], ["MD5 (128bit)", $CALG_MD5], ["SHA1 (160bit)", $CALG_SHA1], ["SHA_256 (256bit)", $CALG_SHA_256], ["SHA_256 (256bit)", $CALG_SHA_256], ["SHA_384 (384bit)", $CALG_SHA_384], ["SHA_512 (512bit)", $CALG_SHA_512]] $hashSelect = GUICtrlRead($idCombo) $hashLoc = _ArraySearch($aCrypt, $hashSelect) $hashAlgo = $aCrypt[$hashLoc][1] $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = Hex($dHash, 8) GUICtrlSetData($g_idOutputEdit, $hexHash) GUICtrlSetTip($g_idOutputEdit, $hexHash) ;ClipPut($hexHash) ; copies hash value to clipboard _Crypt_Shutdown() EndIf EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 If @error Then Return SetError(@error, @extended, -1) While $fKillHash $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf While Not @error $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, FileGetPos($hFile) / $iFileSizeForProgress * 100) WEnd FileClose($hFile) WEnd $fKillHash = True GUICtrlSetData($Progress1, 0) GUICtrlSetState($idStopHashButton, $GUI_DISABLE) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile2 Here's an example that allows you to stop the execution of a function without stopping the entire script: Spoiler Global $fReturn = True HotKeySet('1', '_My_Func') HotKeySet('2', '_Return_All_Func') HotKeySet('{Esc}', '_Exit') While 1 Sleep(50) WEnd Func _My_Func() Local $j = 0, $i_Start = TimerInit() HotKeySet('1') ConsoleWrite($j & ' seconds function works' & @LF) While $fReturn If TimerDiff($i_Start) > 1000 Then $j += 1 ConsoleWrite($j & ' seconds function works' & @LF) $i_Start = TimerInit() EndIf Sleep(50) WEnd ConsoleWrite('function exit - HotKey' & @LF) $fReturn = True HotKeySet('1', '_My_Func') EndFunc ;==>_My_Func Func _Return_All_Func() $fReturn = False EndFunc ;==>_Return_All_Func Func _Exit() Exit EndFunc ;==>_Exit Edited June 10, 2023 by AIG Link to comment Share on other sites More sharing options...
AutoBert Posted June 11, 2023 Share Posted June 11, 2023 Inserting a block like this in the 2. Do .. Until (func _Crypt_HashFile2) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ;ESC => break hashing $vReturn = -1 ExitLoop 2 Case Else ;hash the data EndSwitch is a possible solution wich breaks if user use the X-Button or press ESCape. AIG 1 Link to comment Share on other sites More sharing options...
Andreik Posted June 11, 2023 Share Posted June 11, 2023 (edited) Why not using ward's Machine Code Algorithms that will run each of these hash functions in few milliseconds at worst, so nothing will have to freeze. Edited June 11, 2023 by Andreik AIG 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
TimRude Posted June 12, 2023 Share Posted June 12, 2023 9 hours ago, Andreik said: Why not using ward's Machine Code Algorithms that will run each of these hash functions in few milliseconds at worst, so nothing will have to freeze. A link to the download might be helpful for the OP and anyone else reading this. Link to comment Share on other sites More sharing options...
AIG Posted June 12, 2023 Author Share Posted June 12, 2023 (edited) 22 hours ago, AutoBert said: Inserting a block like this in the 2. Do .. Until (func _Crypt_HashFile2) Thank you for your response. I just saw the solution you suggested. I also managed to stop the hashing process. However, my solution is probably too simple and crude. I used an "If..." statement to check for button press and interrupt the hashing process. Here is the code with your solution: Spoiler expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Array.au3> #include <GuiEdit.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI ;~ Global $StopHas = 0 Global $idStopHasButton Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) $DropLabel = GUICtrlCreateLabel("", 0, 0, 400, 105) GUICtrlSetState(-1, $GUI_DISABLE + $GUI_DROPACCEPTED) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) $idStopHasButton = GUICtrlCreateButton("Stop", 320, 80, 70, 20) GUISetState(@SW_SHOW, $hGUI) $idDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $idDummy]] GUISetAccelerators($aAccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton WinSetOnTop($hGUI, "", 0) Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase WinSetOnTop($hGUI, "", 1) GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_DROPPED If @GUI_DropId = $DropLabel Then GUICtrlSetData($idInput, @GUI_DragFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash(@GUI_DragFile, $Progress1) EndIf Case $idCombo, $idDummy $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFileName, $Progress1) Case $GUI_EVENT_PRIMARYDOWN _GUICtrlEdit_SetSel($idInput, 0, -1) _GUICtrlEdit_SetSel($g_idOutputEdit, 0, -1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else Local $dHash = 0 _Crypt_Startup() Local $aCrypt[8][2] = [["MD2 (128bit)", $CALG_MD2],["MD4 (128bit)", $CALG_MD4],["MD5 (128bit)",$CALG_MD5],["SHA1 (160bit)",$CALG_SHA1],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_384 (384bit)",$CALG_SHA_384],["SHA_512 (512bit)",$CALG_SHA_512]] $hashSelect = GUICtrlRead($idCombo) $hashLoc = _ArraySearch($aCrypt, $hashSelect) $hashAlgo = $aCrypt[$hashLoc][1] $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = $dHash ; Hex($dHash, 8) If $dHash = -1 Then $hexHash = "Hashing process stopped" Else $hexHash = Hex($dHash, 8) EndIf GUICtrlSetData($g_idOutputEdit, $hexHash) GUICtrlSetTip($g_idOutputEdit, $hexHash) ClipPut($hexHash) ; copies hash value to clipboard _Crypt_Shutdown() EndIf EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 ;~ Local $GetStopHasParam = $StopHas If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idStopHasButton $vReturn = -1 ExitLoop 2 Case Else $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf EndSwitch GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile And this is the code with my solution: Spoiler expandcollapse popup#include <Crypt.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Array.au3> #include <GuiEdit.au3> Global $idInput, $g_idOutputEdit, $hashAlgo = $CALG_MD5 Global $idCombo Global $hGUI, $hChildGUI ;~ Global $StopHas = 0 Global $idStopHasButton Example() Func Example() ; Create GUI $hGUI = GUICreate("Hash File", 400, 105, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES)) $DropLabel = GUICtrlCreateLabel("", 0, 0, 400, 105) GUICtrlSetState(-1, $GUI_DISABLE + $GUI_DROPACCEPTED) $idInput = GUICtrlCreateInput("", 10, 20, 300, 20) $sFilePath = GUICtrlRead($idInput) Local $idBrowseButton = GUICtrlCreateButton("Browse", 320, 20, 70, 20) $idCombo = GUICtrlCreateCombo("", 321, 50, 68, 20, $CBS_DROPDOWNLIST) GUICtrlSetData($idCombo, "MD2 (128bit)|MD4 (128bit)|MD5 (128bit)|SHA1 (160bit)|SHA_256 (256bit)|SHA_384 (384bit)|SHA_512 (512bit)", "MD5 (128bit)") $g_idOutputEdit = GUICtrlCreateInput("", 10, 50, 300, 20, BitOR($ES_READONLY, $ES_CENTER)) $Progress1 = GUICtrlCreateProgress(10, 80, 300, 10) $idStopHasButton = GUICtrlCreateButton("Stop", 320, 80, 70, 20) GUISetState(@SW_SHOW, $hGUI) $idDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $idDummy]] GUISetAccelerators($aAccelKeys) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idBrowseButton WinSetOnTop($hGUI, "", 0) Local $sFile = FileOpenDialog("Select file", "", "All (*.*)") If @error Then ContinueCase WinSetOnTop($hGUI, "", 1) GUICtrlSetData($idInput, $sFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFile, $Progress1) Case $GUI_EVENT_DROPPED If @GUI_DropId = $DropLabel Then GUICtrlSetData($idInput, @GUI_DragFile) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash(@GUI_DragFile, $Progress1) EndIf Case $idCombo, $idDummy $sFileName = GUICtrlRead($idInput, 1) GUICtrlSetData($g_idOutputEdit, "") GUICtrlSetTip($g_idOutputEdit, "") _Hash($sFileName, $Progress1) Case $GUI_EVENT_PRIMARYDOWN _GUICtrlEdit_SetSel($idInput, 0, -1) _GUICtrlEdit_SetSel($g_idOutputEdit, 0, -1) EndSwitch WEnd EndFunc ;==>Example Func _Hash($sFile, $Progress1) If Not FileExists($sFile) Then GUICtrlSetData($g_idOutputEdit, "If File not found show this text") Else Local $dHash = 0 _Crypt_Startup() Local $aCrypt[8][2] = [["MD2 (128bit)", $CALG_MD2],["MD4 (128bit)", $CALG_MD4],["MD5 (128bit)",$CALG_MD5],["SHA1 (160bit)",$CALG_SHA1],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_256 (256bit)",$CALG_SHA_256],["SHA_384 (384bit)",$CALG_SHA_384],["SHA_512 (512bit)",$CALG_SHA_512]] $hashSelect = GUICtrlRead($idCombo) $hashLoc = _ArraySearch($aCrypt, $hashSelect) $hashAlgo = $aCrypt[$hashLoc][1] $dHash = _Crypt_HashFile2($sFile, $hashAlgo, $Progress1) $hexHash = $dHash ; Hex($dHash, 8) If $dHash = -1 Then $hexHash = "Hashing process stopped" Else $hexHash = Hex($dHash, 8) EndIf GUICtrlSetData($g_idOutputEdit, $hexHash) GUICtrlSetTip($g_idOutputEdit, $hexHash) ClipPut($hexHash) ; copies hash value to clipboard _Crypt_Shutdown() EndIf EndFunc Func _Crypt_HashFile2($sFilePath, $iAlgID, $Progress1) $iFileSizeForProgress = FileGetSize($sFilePath) Local $dTempData = 0, _ $hFile = 0, $hHashObject = 0, _ $iError = 0, $iExtended = 0, _ $vReturn = 0 ;~ Local $GetStopHasParam = $StopHas If @error Then Return SetError(@error, @extended, -1) Do $hFile = FileOpen($sFilePath, $FO_BINARY) If $hFile = -1 Then $iError = 1 $iExtended = _WinAPI_GetLastError() $vReturn = -1 ExitLoop EndIf Do If GUIGetMsg() = $idStopHasButton Then $vReturn = -1 ExitLoop 2 EndIf $dTempData = FileRead($hFile, 512 * 1024) If @error Then $vReturn = _Crypt_HashData($dTempData, $iAlgID, True, $hHashObject) If @error Then $iError = @error $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf ExitLoop 2 Else $hHashObject = _Crypt_HashData($dTempData, $iAlgID, False, $hHashObject) If @error Then $iError = @error + 100 $iExtended = @extended $vReturn = -1 ExitLoop 2 EndIf EndIf GUICtrlSetData($Progress1, filegetpos($hFile) / $iFileSizeForProgress * 100) Until False Until True GUICtrlSetData($Progress1, 0) If $hFile <> -1 Then FileClose($hFile) Return SetError($iError, $iExtended, $vReturn) EndFunc ;==>_Crypt_HashFile But I noticed that if you include a button press check inside the "Do" loop to interrupt the hashing process, as I did or as you suggested, the file hashing execution process becomes significantly slower. Edited June 12, 2023 by AIG Link to comment Share on other sites More sharing options...
AutoBert Posted June 12, 2023 Share Posted June 12, 2023 36 minutes ago, AIG said: But I noticed that if you include a button press check inside the "Do" loop to interrupt the hashing process, as I did or as you suggested, the file hashing execution process becomes significantly slower. That's the GuiGetMsg, a bigger block in the FileRead helps for getting better performance, using: $dTempData = FileRead($hFile, Ceiling($iFileSizeForProgress / 100)) will effect better performance for files gt 51200 kb, but smaller files will be slower than actual. AIG 1 Link to comment Share on other sites More sharing options...
AIG Posted June 12, 2023 Author Share Posted June 12, 2023 21 hours ago, Andreik said: Why not using ward's Machine Code Algorithms that will run each of these hash functions in few milliseconds at worst, so nothing will have to freeze. If it works as you say, then I won't have to give up the WM_COMMAND function that was used to start the hashing process when performing actions in the GUI. I'll give it a try. 11 hours ago, TimRude said: A link to the download might be helpful for the OP and anyone else reading this. Thanks, got it, I'll see how it works Link to comment Share on other sites More sharing options...
AIG Posted June 12, 2023 Author Share Posted June 12, 2023 (edited) 2 hours ago, AutoBert said: That's the GuiGetMsg, a bigger block in the FileRead helps for getting better performance, using: It really helped to speed up the hashing process. Now the execution speed is approximately the same as in the example provided by Abberration, where there is no interruption in the hashing process. By the way, despite the GUI window freezing in the example I provided earlier in my first post, the file hashing process for an 800-megabyte file is faster than in Abberration's examples. This is most likely due to the processing for the progress bar functionality. I became curious and decided to test it further. I checked a 20-gigabyte file in both scenarios: one with interruption in the hashing process and one without interruption. The results were as follows: the file hashing took 7 minutes in the scenario with the interrupt button and 4 minutes in the scenario without interruption. Edited June 12, 2023 by AIG Link to comment Share on other sites More sharing options...
AutoBert Posted June 13, 2023 Share Posted June 13, 2023 (edited) 21 hours ago, AIG said: I became curious and decided to test it further. I checked a 20-gigabyte file in both scenarios: one with interruption in the hashing process and one without interruption. The results were as follows: the file hashing took 7 minutes in the scenario with the interrupt button and 4 minutes in the scenario without interruption. Also the caches have a effect, i think if you test the non interrupted script first and the interrupted (version with 100 interruptions) the differcence is smaller, maybe the interupted is a little bit faster. Edited June 13, 2023 by AutoBert 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