My primary language is not US/UK. I am using Google Translate.
I'm trying to read the SHA1 of a 6GB ISO file and it's causing the Not Responding issue.
Please help.
This is code.
Code: Select all
EnableExplicit
;- Enumerations
Enumeration Window
#mainWindow
EndEnumeration
Enumeration Gadgets
#Btn_get_SHA1
#String_SHA1
#Txt_1
EndEnumeration
;- Declare
Declare Resize_mainWindow()
Declare Open_mainWindow(X = 0, Y = 0, Width = 490, Height = 70)
Procedure Resize_mainWindow()
Protected mainWindow_WidthIni = 490, mainWindow_HeightIni = 70
Protected ScaleX.f, ScaleY.f
ScaleX = WindowWidth(#mainWindow) / mainWindow_WidthIni : ScaleY = WindowHeight(#mainWindow) / mainWindow_HeightIni
ResizeGadget(#Txt_1, ScaleX * 10, ScaleY * 10, ScaleX * 90, ScaleY * 20)
ResizeGadget(#String_SHA1, ScaleX * 110, ScaleY * 10, ScaleX * 370, ScaleY * 20)
ResizeGadget(#Btn_get_SHA1, ScaleX * 370, ScaleY * 40, ScaleX * 110, ScaleY * 24)
EndProcedure
Procedure Open_mainWindow(X = 0, Y = 0, Width = 490, Height = 70)
If OpenWindow(#mainWindow, X, Y, Width, Height, "get SHA1 without Not Responding Problem", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
TextGadget(#Txt_1, 10, 10, 90, 20, "SHA1 output:")
StringGadget(#String_SHA1, 110, 10, 370, 20, "......", #PB_String_ReadOnly | #ES_CENTER)
ButtonGadget(#Btn_get_SHA1, 370, 40, 110, 24, "get SHA1")
BindEvent(#PB_Event_SizeWindow, @Resize_mainWindow(), #mainWindow)
PostEvent(#PB_Event_SizeWindow, #mainWindow, 0)
ProcedureReturn #True
EndIf
EndProcedure
Global.s vSHA1
Procedure get_SHA1(*File_Name)
;#BufferSize = 16384
;#BufferSize = 65536
Protected *Buffer = AllocateMemory(16384)
Protected.w readByte = 0
Protected outSHA1.s{40}
Protected.d t1 = ElapsedMilliseconds()
Protected.S fn = PeekS(*File_Name)
If (ReadFile(0, GetCurrentDirectory() + fn))
If (*Buffer) And (StartFingerprint(0, #PB_Cipher_SHA1))
readByte = ReadData(0, *Buffer, 16384)
While readByte > 0
AddFingerprintBuffer(0, *Buffer, readByte)
readByte = ReadData(0, *Buffer, 16384)
Wend
CloseFile(0)
outSHA1 = FinishFingerprint(0)
FreeMemory(*Buffer)
EndIf
Else
Debug "File: "+ fn +" not found"
EndIf
vSHA1 = outSHA1
Protected.d t2 = ElapsedMilliseconds()
Debug "Elapsed: "+ StrF((t2-t1)/1000) + " seconds"
Debug vSHA1
EndProcedure
Procedure.s get_SHA1_Thread(*File_Name)
CreateThread(@get_SHA1(), *File_Name)
ProcedureReturn
EndProcedure
;- Main Program
Repeat
Select EventWindow()
Case #mainWindow
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #Btn_get_SHA1
get_SHA1_Thread(@"Win11.iso")
EndSelect
EndSelect
Until WaitWindowEvent() = #PB_Event_CloseWindow