Caesar Cipher Coding Activity
Caesar Cipher Coding Activity
IT16-6727
namespace CeasarCipher
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Function to encrypt the input text using the Caesar Cipher technique
private string Encrypt(string input, int shift)
{
string result = ""; // Initialize result string
// Event handler for text change in the input textbox (currently empty)
private void textBox1_TextChanged(object sender, EventArgs e)
{
// This can be used to handle real-time validation if needed
}
}
}
}
Encryption Process:
• The Encrypt method takes an input string and a shift value.
• It loops through each character of the input text:
• If the character is a letter, it shifts it by the given value within the
alphabet's range using modular arithmetic.
• If the character is not a letter, it remains unchanged.
• The shifted characters are concatenated to form the encrypted result.
Decryption Process:
• The Decrypt method reverses the encryption process by shifting the
characters backward using 26 - shift, effectively undoing the original shift.
• It reuses the Encrypt function by shifting in the opposite direction.