Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Caesars_Cipher
- {
- public partial class CaesarCipherForm : Form
- {
- public CaesarCipherForm()
- {
- InitializeComponent();
- }
- private void EncodeButton_Click(object sender, EventArgs e)
- {
- string decodedString = StringTextBox.Text;
- string encodedString = "";
- for (int i = 0; i < decodedString.Length; i++)
- {
- char thisChar = decodedString[i];
- int encodedValue = (int)thisChar;
- encodedString += encodedValue.ToString("D3") + ",";
- }
- StringTextBox.Text = encodedString;
- }
- private void DecodeButton_Click(object sender, EventArgs e)
- {
- string encodedString = StringTextBox.Text;
- string decodedString = "";
- for (int i = 0; i < encodedString.Length; i += 4)
- {
- string digits = encodedString.Substring(i, 3);
- int numericValue = int.Parse(digits);
- char decodedValue = (char)numericValue;
- decodedString += decodedValue;
- }
- StringTextBox.Text = decodedString;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement