#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $alf = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"
GUICreate("Шифр Цезаря",500,500)
GUICtrlCreateLabel("Ключ сдвига алфавита", 0, 0)
Local $idkey = GUICtrlCreateInput("1",0, 20, 300, 20)
Local $idMyedit1 = GUICtrlCreateEdit("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" & @CRLF, 0,100, 200, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
Local $idMyedit2 = GUICtrlCreateEdit("", 0,200, 200, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
Local $idButton1 = GUICtrlCreateButton("закодировать в цезаря", 220, 100, 185, 25)
Local $idButton2 = GUICtrlCreateButton("раскодировать из цезаря", 220, 200, 185, 25)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton1
;закодировать в шифр цезаря
$text = GUICtrlRead($idMyedit1)
local $y = ""
Local $key = GUICtrlRead($idkey)
local $n = 33
for $symbol = 1 to StringLen($text)
for $i = 1 to $n+1
if (StringMid($text,$symbol,1) = StringMid($alf,$i,1)) then
local $indexsymbol = Mod($i,$n)+$key
$y = $y & ( StringMid($text,$symbol,1) & " = " & StringMid($alf,$indexsymbol,1) & @CRLF)
endif
next
next
GUICtrlSetData($idMyedit1, "")
GUICtrlSetData($idMyedit2, "")
GUICtrlSetData($idMyedit1, StringUpper($text), 1)
GUICtrlSetData($idMyedit2, StringUpper($y), 1)
Case $idButton2
;раскодировать из цезаря
$text = GUICtrlRead($idMyedit2)
local $x = ""
Local $key = GUICtrlRead($idkey)
local $n = 33
for $symbol = 1 to StringLen($text)
for $i = 1 to $n+1
if (StringMid($text,$symbol,1) = StringMid($alf,$i,1)) then
local $indexsymbol = Mod($i,$n) + $key
$x = $x & StringMid($alf,$indexsymbol,1) & " = " & StringMid($text,$symbol,1)
endif
next
next
GUICtrlSetData($idMyedit1, "")
GUICtrlSetData($idMyedit1, StringUpper($x), 1)
EndSwitch
WEnd
|