LoginSignup
0
0

More than 1 year has passed since last update.

cscの作法 その170

Last updated at Posted at 2022-05-25

概要

cscの作法、調べてみた。
base64やってみた。

写真

image.png

サンプルコード

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;

namespace app
{
	public class Form1 : Form {
		private Button button1;
		private Button button2;
		private TextBox textBox1;
		private TextBox textBox2;
		private TextBox textBox3;
		public Form1() {
			this.button1 = new Button();
			this.button2 = new Button();
			this.textBox1 = new TextBox();
			this.textBox2 = new TextBox();
			this.textBox3 = new TextBox();
			this.button1.Location = new System.Drawing.Point(300, 130);
			this.button1.Name = "button1";
			this.button1.TabIndex = 0;
			this.button1.Text = "enc";
			this.button1.Click += new System.EventHandler(this.button1_Click);

			this.button2.Location = new System.Drawing.Point(300, 270);
			this.button2.Name = "button1";
			this.button2.TabIndex = 0;
			this.button2.Text = "dec";
			this.button2.Click += new System.EventHandler(this.button2_Click);

			this.textBox1.Location = new System.Drawing.Point(30, 20);
			this.textBox1.Multiline = true;
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(300, 100);
			this.textBox1.TabIndex = 2;
			this.textBox1.Text = "base64 テストコード";

			this.textBox2.Location = new System.Drawing.Point(30, 160);
			this.textBox2.Multiline = true;
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(300, 100);
			this.textBox2.TabIndex = 2;
			this.textBox2.Text = "";

			this.textBox3.Location = new System.Drawing.Point(30, 300);
			this.textBox3.Multiline = true;
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(300, 100);
			this.textBox3.TabIndex = 2;
			this.textBox3.Text = "";

			this.ClientSize = new System.Drawing.Size(400, 500);
			this.Controls.AddRange(new Control[] {
				this.button1,
				this.button2,
				this.textBox1,
				this.textBox2,
				this.textBox3
			});
			this.Name = "Form1";
			this.Text = "base64";
		}
		private void button1_Click(object sender, System.EventArgs e) {
			this.textBox2.Text = Convert.ToBase64String(Encoding.UTF8.GetBytes(this.textBox1.Text));
		}
		private void button2_Click(object sender, System.EventArgs e) {
			this.textBox3.Text = Encoding.UTF8.GetString(Convert.FromBase64String(this.textBox2.Text));
		}
		[STAThread]
		static void Main() {
			Application.Run(new Form1());
		}
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0