Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Dim $Matrice[256][256]
$StringMatrice = ""
For $i = 0 To 255
$StringMatrice = $StringMatrice & Chr($i)
Next
For $i = 0 To 255
For $j = 0 To 255
$Matrice[$i][$j] = StringMid($StringMatrice, $j , 1)
Next
$StringMatrice = StringRight($StringMatrice, 1) & StringTrimRight($StringMatrice, 1)
Next
$Form1 = GUICreate("Form1", 562, 413, 192, 114)
$Label1 = GUICtrlCreateLabel("Cle", 16, 8, 19, 17)
$Input1 = GUICtrlCreateInput("", 16, 32, 529, 21)
$Label2 = GUICtrlCreateLabel("Source", 16, 64, 38, 17)
$Edit1 = GUICtrlCreateEdit("", 16, 88, 529, 113)
$Button1 = GUICtrlCreateButton("traiter", 32, 216, 75, 25, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("Destination", 16, 256, 57, 17)
$Edit2 = GUICtrlCreateEdit("", 16, 280, 529, 113)
GUISetState(@SW_SHOW)
$Label1Bis = GUICtrlCreateLabel("", 45, 8, 200, 17) ;=<<<<<<<<<<<<
$iNB = -1 ;=<<<<<<<<<<<<
$iLongCle = 0 ;=<<<<<<<<<<<<
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_chiffre(GUICtrlRead($Edit1), GUICtrlRead($Input1))
EndSwitch
Sleep(10) ;=<<<<<<<<<<<<
If ($iLongCle <> StringLen(GUICtrlRead($Edit1))) Or ($iNB <> StringLen(GUICtrlRead($Input1))) Then ;=<<<<<<<<<<<<
$iLongCle = StringLen(GUICtrlRead($Edit1)) ;=<<<<<<<<<<<<
$iNB = StringLen(GUICtrlRead($Input1)) ;=<<<<<<<<<<<<
If $iLongCle > 0 Then ;=<<<<<<<<<<<<
Switch $iNB ;=<<<<<<<<<<<<
Case 0 To $iLongCle -1 ;=<<<<<<<<<<<<
GUICtrlSetData($Label1Bis, "Saisir encore " & $iLongCle - $iNB & " caractères") ;=<<<<<<<<<<<<
Case $iLongCle ;=<<<<<<<<<<<<
GUICtrlSetData($Label1Bis, "La longueur de la clé est OK") ;=<<<<<<<<<<<<
Case Else ;=<<<<<<<<<<<<
GUICtrlSetData($Label1Bis, "Vous avez saisi " & $iNB - $iLongCle & " caractères en trop") ;=<<<<<<<<<<<<
EndSwitch ;=<<<<<<<<<<<<
EndIf
EndIf ;=<<<<<<<<<<<<
WEnd
Func _chiffre($Txt_Source, $Cle)
While StringLen($Cle) < StringLen($Txt_Source)
$Cle = $Cle & $Cle
WEnd
$Txt_Traite = ""
For $i = 1 To StringLen($Txt_Source)
$Txt_Traite = $Txt_Traite & $Matrice[Asc(StringMid($Txt_Source, $i, 1))][Asc(StringMid($Cle, $i, 1))]
Next
GUICtrlSetData($Edit2, $Txt_Traite)
EndFunc ;==>_chiffre