using Pilz.Cryptography; using Pilz.Tools.Symbols; using Telerik.WinControls.UI; namespace Pilz.Tools.StringCrypter; public partial class Form1 : RadForm { private ICrypter? crypter; public Form1() { InitializeComponent(); radButton_Copy.SvgImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.copy, UI.Symbols.SymbolSize.x16); radButton_Paste.SvgImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.paste_as_text, UI.Symbols.SymbolSize.x16); } private void RadButton_Copy_Click(object sender, EventArgs e) { Clipboard.SetText(radTextBox_Output.Text); } private void RadButton_Paste_Click(object sender, EventArgs e) { radTextBox_Input.Text = Clipboard.GetText(); } private void RadToggleSwitch_Mode_ValueChanged(object sender, EventArgs e) { DoEncryption(); } private void RadTextBox_Key_TextChanged(object sender, EventArgs e) { crypter = null; DoEncryption(); } private void RadTextBox_Input_TextChanged(object sender, EventArgs e) { DoEncryption(); } private void DoEncryption() { crypter ??= new SimpleStringCrypter(radTextBox_Key.Text); try { if (radToggleSwitch_Mode.Value) radTextBox_Output.Text = crypter.Encrypt(radTextBox_Input.Text); else radTextBox_Output.Text = crypter.Decrypt(radTextBox_Input.Text); } catch (Exception) { radTextBox_Output.Text = null; } } }