#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, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
Local $idMyedit2 = GUICtrlCreateEdit("", 0,200, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
Local $idButton1 = GUICtrlCreateButton("закодировать в цезаря", 120, 100, 185, 25)
Local $idButton2 = GUICtrlCreateButton("раскодировать из цезаря", 120, 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 = 0 to 33
if StringMid($text,$symbol,1) = StringMid($alf,$i,1) then $y = $y & StringMid($alf,Mod($i+$key,$n+1),1)
next
next
msgbox(0,"tilte", $y)
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 = 0 to 33
if StringMid($text,$symbol,1) = StringMid($alf,$i,1) then $x = $x & StringMid($alf,Mod($i-$key,$n+1),1)
next
next
msgbox(0,"tilte", $x)
GUICtrlSetData($idMyedit1, "")
GUICtrlSetData($idMyedit1, StringUpper($x), 1)
EndSwitch
WEnd
|