using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace XOrMetinSifrele
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private Button button2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override **** Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
///
/// The main entry point for the application.
///
[STAThread]
static **** Main()
{
Application.Run(new Form1());
}
bool sifreliMi = false;
private **** button1_Click(object sender, System.EventArgs e)
{
string metin, ŞifreliMetin = "";
int i;
byte c, şifre;
//metin = textBox1.Text;
metin = dataOku();
try
{
şifre = byte.Parse(textBox2.Text);
}
catch
{
MessageBox.Show("Şifre olarak 0-255 arası bir sayı girin");
return;
}
if (sifreliMi)
{
metin = textBox3.Text;
}
//Şifreleme veya şifreyi çözme işlemi
for (i = 0; i <= metin.Length - 1; i++)
{
if (metin == 'a' || metin == 'z' || metin == 'A' ||
metin == 'Z' || metin == ' ' || metin == '\n' || metin == '\r')
c = (byte)metin;
else
{
c = (byte)(metin ^ şifre);
}
ŞifreliMetin = ŞifreliMetin + (char)(c);
}
textBox3.Text = ŞifreliMetin;
sifreliMi = !sifreliMi;
datayaz(textBox3.Text);
}
string dataOku()
{
//dosyayı oku ve içeriğin geri string tipinde geri dön
//Read the contents
StreamReader streamReader;
streamReader = File.OpenText("d:\\TestFile.txt");
string strContent = streamReader.ReadToEnd();
//dosyayı sonuna kadar oku ve bu değere ata
streamReader.Close();
return strContent;//dosya içeri geri dönme
}
**** datayaz(string data)
{
//bu metoda gelen data değerini dosyaya yaz
StreamWriter streamWriter;
streamWriter = File.CreateText("d:\\TestFile.txt");
streamWriter.Write(data); // datayı dosyaya yazma
streamWriter.Close();
//Append contents
streamWriter = File.AppendText("C:\\TestFile.txt");
//Eğer istenirse aşağıdaki gibidosyaya ek yapılabilir
streamWriter.WriteLine("Third line");
streamWriter.Close();
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private **** InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.******** = new System.Drawing.Point(0, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Metin:";
//
// label2
//
this.label2.******** = new System.Drawing.Point(0, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(152, 23);
this.label2.TabIndex = 1;
this.label2.Text = "Şifre
0-255)";
//
// label3
//
this.label3.******** = new System.Drawing.Point(0, 88);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(152, 23);
this.label3.TabIndex = 2;
this.label3.Text = "Kodlanmış/Çözülmüş Metin:";
//
// textBox1
//
this.textBox1.******** = new System.Drawing.Point(152, 8);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.******** = new System.Drawing.Point(152, 48);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.******** = new System.Drawing.Point(152, 88);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 5;
this.textBox3.Text = "textBox3";
//
// button1
//
this.button1.******** = new System.Drawing.Point(152, 120);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 23);
this.button1.TabIndex = 6;
this.button1.Text = "Şifrele/Çöz";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(264, 150);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private **** Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace XOrMetinSifrele
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private Button button2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override **** Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
///
/// The main entry point for the application.
///
[STAThread]
static **** Main()
{
Application.Run(new Form1());
}
bool sifreliMi = false;
private **** button1_Click(object sender, System.EventArgs e)
{
string metin, ŞifreliMetin = "";
int i;
byte c, şifre;
//metin = textBox1.Text;
metin = dataOku();
try
{
şifre = byte.Parse(textBox2.Text);
}
catch
{
MessageBox.Show("Şifre olarak 0-255 arası bir sayı girin");
return;
}
if (sifreliMi)
{
metin = textBox3.Text;
}
//Şifreleme veya şifreyi çözme işlemi
for (i = 0; i <= metin.Length - 1; i++)
{
if (metin == 'a' || metin == 'z' || metin == 'A' ||
metin == 'Z' || metin == ' ' || metin == '\n' || metin == '\r')
c = (byte)metin;
else
{
c = (byte)(metin ^ şifre);
}
ŞifreliMetin = ŞifreliMetin + (char)(c);
}
textBox3.Text = ŞifreliMetin;
sifreliMi = !sifreliMi;
datayaz(textBox3.Text);
}
string dataOku()
{
//dosyayı oku ve içeriğin geri string tipinde geri dön
//Read the contents
StreamReader streamReader;
streamReader = File.OpenText("d:\\TestFile.txt");
string strContent = streamReader.ReadToEnd();
//dosyayı sonuna kadar oku ve bu değere ata
streamReader.Close();
return strContent;//dosya içeri geri dönme
}
**** datayaz(string data)
{
//bu metoda gelen data değerini dosyaya yaz
StreamWriter streamWriter;
streamWriter = File.CreateText("d:\\TestFile.txt");
streamWriter.Write(data); // datayı dosyaya yazma
streamWriter.Close();
//Append contents
streamWriter = File.AppendText("C:\\TestFile.txt");
//Eğer istenirse aşağıdaki gibidosyaya ek yapılabilir
streamWriter.WriteLine("Third line");
streamWriter.Close();
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private **** InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.******** = new System.Drawing.Point(0, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Metin:";
//
// label2
//
this.label2.******** = new System.Drawing.Point(0, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(152, 23);
this.label2.TabIndex = 1;
this.label2.Text = "Şifre
//
// label3
//
this.label3.******** = new System.Drawing.Point(0, 88);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(152, 23);
this.label3.TabIndex = 2;
this.label3.Text = "Kodlanmış/Çözülmüş Metin:";
//
// textBox1
//
this.textBox1.******** = new System.Drawing.Point(152, 8);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.******** = new System.Drawing.Point(152, 48);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.******** = new System.Drawing.Point(152, 88);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 20);
this.textBox3.TabIndex = 5;
this.textBox3.Text = "textBox3";
//
// button1
//
this.button1.******** = new System.Drawing.Point(152, 120);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 23);
this.button1.TabIndex = 6;
this.button1.Text = "Şifrele/Çöz";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(264, 150);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private **** Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}



