Function Reference


_WinAPI_HashString

Hashes a string

#include <WinAPIConv.au3>
_WinAPI_HashString ( $sString [, $bCaseSensitive = True [, $iLength = 32]] )

Parameters

$sString The string to hash.
$bCaseSensitive [optional] Specifies whether to treat the string as case sensitive when computing the hash value, valid values:
True - The lowercase and uppercase string hash to the different value (Default).
False - The lowercase and uppercase string hash to the same value.
$iLength [optional] The length of the hash data, in bytes. It should be no larger than 256, otherwise, the function fails. Default is 32.

Return Value

Success: The hash data in binary form.
Failure: Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIConv.au3>
#include <WindowsConstants.au3>

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 96)
Global $g_idInput1 = GUICtrlCreateInput('', 20, 20, 360, 20)
GUICtrlSetLimit(-1, 255)
Global $g_idInput2 = GUICtrlCreateInput('', 20, 56, 360, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch _WinAPI_LoWord($wParam)
                Case $g_idInput1
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_CHANGE
                            Local $dHash
                            $dHash = _WinAPI_HashString(GUICtrlRead($g_idInput1), False, 16)
                            If Not @error Then
                                GUICtrlSetData($g_idInput2, $dHash)
                            Else
                                GUICtrlSetData($g_idInput2, '')
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND