public void Encrypt_Clicked(object sender, EventArgs e)
{
if (txtPlainText != null)
{
string ciphertext = Encipher(txtPlainText,);
}
}
public void Decrypt_Clicked(object sender, EventArgs e)
{
if (txtEncryptedText != null)
{
string Deciphertext = Decipher(txtEncryptedText,);
}
}
public static string Encipher(string input, int key)
{
string output = string.Empty;
foreach (char ch in input)
output += cipher(ch, key);
return output;
}
public static string Decipher(string input, int key)
{
return Encipher(input, 26 - key);
}
public static char cipher(char ch, int key)
{
if (!char.IsLetter(ch))
{
return ch;
}
char d = char.IsUpper(ch) ? 'A' : 'a';
return (char)((((ch + key) - d) % 26) + d);
}
}
}
I have this so far but I am not sure how to accept the user input and run the code when the buttons are pressed.