Salut,
Juste un petit exemple sur comment créer un inputbox personnalisé, et comment "sécuriser" un programme AutoIt Avec hashage d'un mot de passe :
Good bye.
Juste un petit exemple sur comment créer un inputbox personnalisé, et comment "sécuriser" un programme AutoIt Avec hashage d'un mot de passe :
Code:
#include <Crypt.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $__ConfigIni = @ScriptDir & "\cfg.ini"
#Region - ### Security ###
Global $read
Global $__pass = IniRead($__ConfigIni, "securite", "key", "0")
If $__pass = "0" Then
$read = _pwInput("Upload", "Please create a password")
If @error Or $read = "" Then
Exit
Else
IniWrite($__ConfigIni, "securite", "key", _Crypt_HashData($read, $CALG_SHA1))
Exit
EndIf
Else
$read = _pwInput("Upload", "Password")
If @error Or $read = "" Then
Exit
Else
If _Crypt_HashData($read, $CALG_SHA1) <> $__pass Then
Exit
EndIf
EndIf
EndIf
$__pass = 0
$read = 0
#EndRegion ###
MsgBox(0, "", "Le programme se lance...")
; ==============================================================
; ### Functions
; ==============================================================
Func _pwInput($sTitle, $sText, $iTimeOut = 0)
Local $_xx_passForm, $_xx_Label, $_xx_Input
Local $_xx_B_OK, $_xx_B_Cancel, $nMsg
Local $timer, $timedOut = 0, $canceled = 0
Local $readText
$iTimeOut = $iTimeOut * 1000
#Region ### START Koda GUI section ### Form=
$_xx_passForm = GUICreate($sTitle, 294, 106)
$_xx_Label = GUICtrlCreateLabel($sText, 5, 5, 281, 32)
$_xx_Input = GUICtrlCreateInput("", 5, 40, 281, 21, $ES_PASSWORD)
$_xx_B_OK = GUICtrlCreateButton("OK", 205, 70, 75, 25, $WS_GROUP + $BS_DEFPUSHBUTTON)
$_xx_B_Cancel = GUICtrlCreateButton("Cancel", 125, 70, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$timer = TimerInit()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$canceled = 1
ExitLoop
Case $_xx_B_Cancel
$canceled = 1
ExitLoop
Case $_xx_B_OK
ExitLoop
EndSwitch
If TimerDiff($timer) >= $iTimeOut And $iTimeOut <> 0 Then
$timedOut = 1
ExitLoop
EndIf
WEnd
$readText = GuiCtrlRead($_xx_Input)
GuiDelete($_xx_passForm)
If $timedOut Then Return SetError(2, 0, "")
If $canceled Then Return SetError(1, 0, "")
Return SetError(0, 0, $readText)
EndFunc
Good bye.