#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include  <Crypt.au3>

$hGUI = GUICreate("Passwordcreator", 500, 170)
GUICtrlCreateLabel("Benutzername:", 5, 5, 85, 21)
$idInpUser = GUICtrlCreateInput("", 95, 5, 190, 21)
GUICtrlCreateLabel("Passwort:", 5, 35, 85, 21)
$idInpPW = GUICtrlCreateInput("", 95, 35, 190, 21)
GUICtrlCreateLabel("PW bestätigen:", 5, 65, 85, 21)
$idInpPW2 = GUICtrlCreateInput("", 95, 65, 190, 21) ; Input mit Passwort Style...
$idBtnCreate = GUICtrlCreateButton("&Passwort erzeugen", 5, 98, 490, 70)
GUISetState(@SW_SHOW)
$sSalt = "Most recent sig. I made"

While 1
	$CreateState = GUICtrlGetState($idBtnCreate)
	;ermitteln welchen Status der Create-Button hat
	$sPW1 =  GUICtrlRead($idInpPW)
	$sPW2 = GUICtrlRead($idInpPW2)
	If $sPW1		= $sPW2 And StringLen($sPW1) > 3 And GUICtrlRead($idInpUser) <> ""  Then
		;Wenn beide Passworteingaben übereinstimmen und das PW  mind. 4stellig ist und ein Benutzer eingegeben dann
		If BitAND($CreateState, $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetState($idBtnCreate, $GUI_Enable)
		;Wenn $CreateState nicht aktiv (also der Createbutton nicht klickbar) ist dann Create-Button aktivieren
	Else
		;ansonsten
		If BitAND($CreateState, $GUI_Enable) = $GUI_Enable Then GUICtrlSetState($idBtnCreate, $GUI_DISABLE)
		;Wenn $CreateState aktiv (also der Createbutton klickbar) ist dann Create-Button deaktivieren
	EndIf
	$msg = GUIGetMsg()
	Switch $msg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $idBtnCreate
			;Createbutton wurde geklickt
			$sPass=_Crypt_HashData(GUICtrlRead($idInpPW) & $sSalt, $CALG_MD5)
			IniWrite(@ScriptDir&"\PW_List.ini","User",GUICtrlRead($idInpUser),$sPass)
	EndSwitch
WEnd