Не выводится текст в текст бокс c#
Нужно вывести в TextBox2 значение переменной encryptedText
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Diplom
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public class VigenereCipher
{
const string defaultAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly string letters;
public VigenereCipher(string alphabet = null)
{
letters = string.IsNullOrEmpty(alphabet) ? defaultAlphabet : alphabet;
}
//генерация повторяющегося пароля
private string GetRepeatKey(string s, int n)
{
var p = s;
while (p.Length < n)
{
p += p;
}
return p.Substring(0, n);
}
private string Vigenere(string text, string password, bool encrypting = true)
{
var gamma = GetRepeatKey(password, text.Length);
var retValue = "";
var q = letters.Length;
for (int i = 0; i < text.Length; i++)
{
var letterIndex = letters.IndexOf(text[i]);
var codeIndex = letters.IndexOf(gamma[i]);
if (letterIndex < 0)
{
//если буква не найдена, добавляем её в исходном виде
retValue += text[i].ToString();
}
else
{
retValue += letters[(q + letterIndex + ((encrypting ? 1 : -1) * codeIndex)) % q].ToString();
}
}
return retValue;
}
//шифрование текста
public string Encrypt(string plainMessage, string password)
=> Vigenere(plainMessage, password);
//дешифрование текста
public string Decrypt(string encryptedMessage, string password)
=> Vigenere(encryptedMessage, password, false);
}
public void imho()
{
var cipher = new VigenereCipher("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ");
var inputText = textBox1.Text;
var password = textBox3.Text;
var encryptedText = cipher.Encrypt(inputText, password);
textBox2.Text = encryptedText;
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Show();
}
}
}