Jump to content

Basit Bir Md5 Hesaplayıcısı


Sapider

Recommended Posts

#cs ----------------------------------------------------------------------------

    AutoIt Version : 3.3.6.1
    Açıklama ......: Dosyalarınızın MD5 değerlerini hesaplar.
    Tarih .........: 25 Nisan 2010 Pazar
    Yazar .........: ripdad
    Web ...........: http://www.autoitscript.com/forum/index.php?showtopic=112711

#ce ----------------------------------------------------------------------------

Global $sFile
Global $gui00 = GUICreate("MD5 Hesaplayıcısı", 320, 150, -1, -1)
Global $inp01 = GUICtrlCreateInput("", 35, 30, 250, 20)
Global $inp02 = GUICtrlCreateInput("", 35, 70, 250, 20)
Global $btn01 = GUICtrlCreateButton("Dosya Aç", 20, 115, 70, 25)
Global $btn02 = GUICtrlCreateButton("Hash Kopyala", 120, 115, 80, 25)
Global $btn03 = GUICtrlCreateButton("Çıkış", 230, 115, 70, 25)
GUICtrlCreateGroup("Dosya ve MD5 Değeri", 20, 10, 280, 95)
GUISetState(@SW_SHOW, $gui00)
;
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3, $btn03
            ExitLoop
        Case $btn01
            $sFile = FileOpenDialog("Aç", @ScriptDir, "Tüm Dosyalar (*.*)", 1)
            If $sFile Then
                GUICtrlSetData($inp01, $sFile)
                GUICtrlSetData($inp02, _MD5($sFile))
            Else
                ContinueLoop
            EndIf
        Case $btn02
            ClipPut(GUICtrlRead($inp02))
    EndSwitch
WEnd
GUIDelete($gui00)
Exit

Func _MD5($sFile)
    Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _
            "wstr", $sFile, _
            "dword", 0x80000000, _
            "dword", 3, _
            "ptr", 0, _
            "dword", 3, _
            "dword", 0, _
            "ptr", 0)
    If @error Or $a_hCall[0] = -1 Then
        Return SetError(1, 0, "")
    EndIf
    Local $hFile = $a_hCall[0]
    $a_hCall = DllCall("kernel32.dll", "ptr", "CreateFileMappingW", _
            "hwnd", $hFile, _
            "dword", 0, _
            "dword", 2, _
            "dword", 0, _
            "dword", 0, _
            "ptr", 0)
    If @error Or Not $a_hCall[0] Then
        DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile)
        Return SetError(2, 0, "")
    EndIf
    DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFile)
    Local $hFileMappingObject = $a_hCall[0]
    $a_hCall = DllCall("kernel32.dll", "ptr", "MapViewOfFile", _
            "hwnd", $hFileMappingObject, _
            "dword", 4, _
            "dword", 0, _
            "dword", 0, _
            "dword", 0)
    If @error Or Not $a_hCall[0] Then
        DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject)
        Return SetError(3, 0, "")
    EndIf
    Local $pFile = $a_hCall[0]
    Local $iBufferSize = FileGetSize($sFile)
    Local $tMD5_CTX = DllStructCreate("dword i[2];" & _
            "dword buf[4];" & _
            "ubyte in[64];" & _
            "ubyte digest[16]")
    DllCall("advapi32.dll", "none", "MD5Init", "ptr", DllStructGetPtr($tMD5_CTX))
    If @error Then
        DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile)
        DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject)
        Return SetError(4, 0, "")
    EndIf
    DllCall("advapi32.dll", "none", "MD5Update", _
            "ptr", DllStructGetPtr($tMD5_CTX), _
            "ptr", $pFile, _
            "dword", $iBufferSize)
    If @error Then
        DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile)
        DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject)
        Return SetError(5, 0, "")
    EndIf
    DllCall("advapi32.dll", "none", "MD5Final", "ptr", DllStructGetPtr($tMD5_CTX))
    If @error Then
        DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile)
        DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject)
        Return SetError(6, 0, "")
    EndIf
    DllCall("kernel32.dll", "int", "UnmapViewOfFile", "ptr", $pFile)
    DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hFileMappingObject)
    Local $sMD5 = Hex(DllStructGetData($tMD5_CTX, "digest"))
    Return SetError(0, 0, $sMD5)
EndFunc;==>_MD5
;[/CODE]

Link to comment
Share on other sites

  • 2 hafta sonra ...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...