Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- StringBuilder text = new StringBuilder(textBox2.Text);
- progressBar1.Maximum = text.Length;
- progressBar1.Value = 0;
- string key = textBox3.Text.ToUpper();
- int j = 0;
- for (int i = 0; i < text.Length; i++)
- {
- int newCode = text[i] + (key[j] - 64);
- if(char.IsUpper(text[i]) && newCode > 90)
- {
- text[i] = (char)(64 + newCode - 90);
- }
- if(char.IsLower(text[i]) && newCode > 122)
- {
- text[i] = (char)(96 + newCode - 122);
- }
- else
- {
- text[i] = (char)newCode;
- }
- if (j == key.Length - 1)
- j = 0;
- else
- j++;
- progressBar1.Value++;
- }
- textBox1.Text = text.ToString();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- StringBuilder text = new StringBuilder(textBox2.Text);
- progressBar1.Maximum = text.Length;
- progressBar1.Value = 0;
- string key = textBox3.Text.ToUpper();
- int j = 0;
- for (int i = 0; i < text.Length; i++)
- {
- int newCode = text[i] - (key[j] - 64);
- if (char.IsUpper(text[i]) && newCode < 65)
- {
- text[i] = (char)(91 - (65 - newCode));
- }
- if (char.IsLower(text[i]) && newCode < 97)
- {
- text[i] = (char)(123- ( 97- newCode));
- }
- else
- {
- text[i] = (char)newCode;
- }
- if (j == key.Length - 1)
- j = 0;
- else
- j++;
- progressBar1.Value++;
- }
- textBox1.Text = text.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement