در حال بارگذاری صفحه...


namespace persianedito
{
class sezaralgorithm
{
public int upreToint(char ch)
{
return ch - 65;
}
public int lowerToint(char ch)
{
return ch - 97;
}
public int intToUper(int value)
{
return (char)(value+65);
}
public int intTolower(int value)
{
return (char)(value+97);
}
public bool islower(char ch)
{
if (ch >= 97 && ch <= 122)
{
return true;
}
else
{
return false;
}
}
public bool isUper(char ch)
{
if (ch >= 65 && ch <= 90)
{
return true;
}
else
{
return false;
}
}
public string encryption(string textToencryption, char key)
{
char[] plaintext = textToencryption.ToCharArray();
char[] cipher = new char[textToencryption.Length];
}
for (int i = 0; i < textToencryption.Length; i++)
{
if (islower(plaintext[i]) == true)
{
ciphertext[i] = intTolower((lowerToint(plaintext[i]) + upreToint(key)) % 26);
}
if (isUper(plaintext[i]) == true)
{
ciphertext[i] = intToUper((upreToint(plaintext[i]) + upreToint(key)) % 26);
}
string cipher = "";
for (int i = 0; i < textToencryption.Length; i++)
{
cipher += ciphertext[i].ToString();
}
public string decription(string textTodecription, char key)
{
string plain = "";
char[] plaintext = new char[textTodecription.Length];
char[] ciphertext = textTodecription.ToCharArray();
for (int i = 0; i < textTodecription.Length; i++)
{
if (islower(ciphertext[i]) == true)
{
plaintext[i] = intTolower((lowerToint(ciphertext[i]) + upreToint(key)) % 26);
}
if (isUper(plaintext[i]) == true)
{
plaintext[i] = intToUper((upreToint(ciphertext[i]) + upreToint(key)) % 26);
}
}
for (int i = 0; i < textTodecription.Length; i++)
{
plain += plaintext[i].ToString();
return plain;
}
}
private void btnencripttext_Click(object sender, EventArgs e)
{
sezaralgorithm sezar = new sezaralgorithm();
txtcipher.Text = sezar.encription(txtplain.Text, Convert.ToChar(cmbKey.Text));
}

private void btnplainbrows_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
}
}
namespace persianedito
{
public partial class frmencription : Form
{
string plaintext = "";
string ciphertext = "";
در گام بعدی متن را از فایل انتخاب شده میخوانیم و در متغییر plaintext قرار میدهیم.
private void btnplainbrows_Click(object sender, EventArgs e)
{
string plaintext = "", ciphertext = "";
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
plaintext = System.IO.File.ReadAllText(txtplainfilename.Text);
}
}
private void btnplainbrows_Click(object sender, EventArgs e)
{
string plaintext = "", ciphertext = "";
sezaralgorithm sezar = new sezaralgorithm();
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
plaintext = System.IO.File.ReadAllText(txtplainfilename.Text);
ciphertext = sezar.encription(plaintext, Convert.ToChar(cmbfilekey));
}
}

private void btncipherbrows_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtcipherfilename.Text = saveFileDialog1.FileName;
System.IO.File.WriteAllText(saveFileDialog1.FileName,ciphertext);
}
}
private void btncipttext_Click(object sender, EventArgs e)
{
sezaralgorithm sezar = new sezaralgorithm();
txtplain.Text = sezar.decription(txtcipher.Text, Convert.ToChar(cmbKey.Text));
}


از سال 1380 برنامه نویسی را شروع کرده و از سال 90 در این زمینه تدریس میکنم .با زبانهای سی پلاس پلاس ، سی ،پاسکال ،VB ، سی شارپ ،اسمبلی، جاوا و .... کار کرده و آنها را تدریس کرده ام.هم اکنون نیز مشغول تدریس در دانشگاه هستم و مدتی است با سایت درسمن همکاری میکنم.
هنوز اینجا کامنتی ثبت نشده

namespace persianedito
{
class sezaralgorithm
{
public int upreToint(char ch)
{
return ch - 65;
}
public int lowerToint(char ch)
{
return ch - 97;
}
public int intToUper(int value)
{
return (char)(value+65);
}
public int intTolower(int value)
{
return (char)(value+97);
}
public bool islower(char ch)
{
if (ch >= 97 && ch <= 122)
{
return true;
}
else
{
return false;
}
}
public bool isUper(char ch)
{
if (ch >= 65 && ch <= 90)
{
return true;
}
else
{
return false;
}
}
public string encryption(string textToencryption, char key)
{
char[] plaintext = textToencryption.ToCharArray();
char[] cipher = new char[textToencryption.Length];
}
for (int i = 0; i < textToencryption.Length; i++)
{
if (islower(plaintext[i]) == true)
{
ciphertext[i] = intTolower((lowerToint(plaintext[i]) + upreToint(key)) % 26);
}
if (isUper(plaintext[i]) == true)
{
ciphertext[i] = intToUper((upreToint(plaintext[i]) + upreToint(key)) % 26);
}
string cipher = "";
for (int i = 0; i < textToencryption.Length; i++)
{
cipher += ciphertext[i].ToString();
}
public string decription(string textTodecription, char key)
{
string plain = "";
char[] plaintext = new char[textTodecription.Length];
char[] ciphertext = textTodecription.ToCharArray();
for (int i = 0; i < textTodecription.Length; i++)
{
if (islower(ciphertext[i]) == true)
{
plaintext[i] = intTolower((lowerToint(ciphertext[i]) + upreToint(key)) % 26);
}
if (isUper(plaintext[i]) == true)
{
plaintext[i] = intToUper((upreToint(ciphertext[i]) + upreToint(key)) % 26);
}
}
for (int i = 0; i < textTodecription.Length; i++)
{
plain += plaintext[i].ToString();
return plain;
}
}
private void btnencripttext_Click(object sender, EventArgs e)
{
sezaralgorithm sezar = new sezaralgorithm();
txtcipher.Text = sezar.encription(txtplain.Text, Convert.ToChar(cmbKey.Text));
}

private void btnplainbrows_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
}
}
namespace persianedito
{
public partial class frmencription : Form
{
string plaintext = "";
string ciphertext = "";
در گام بعدی متن را از فایل انتخاب شده میخوانیم و در متغییر plaintext قرار میدهیم.
private void btnplainbrows_Click(object sender, EventArgs e)
{
string plaintext = "", ciphertext = "";
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
plaintext = System.IO.File.ReadAllText(txtplainfilename.Text);
}
}
private void btnplainbrows_Click(object sender, EventArgs e)
{
string plaintext = "", ciphertext = "";
sezaralgorithm sezar = new sezaralgorithm();
if (openFileDialog1.ShowDialog() == DialogResult.ok)
{
txtplainfilename.Text = openFileDialog1.FileName;
plaintext = System.IO.File.ReadAllText(txtplainfilename.Text);
ciphertext = sezar.encription(plaintext, Convert.ToChar(cmbfilekey));
}
}

private void btncipherbrows_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtcipherfilename.Text = saveFileDialog1.FileName;
System.IO.File.WriteAllText(saveFileDialog1.FileName,ciphertext);
}
}
private void btncipttext_Click(object sender, EventArgs e)
{
sezaralgorithm sezar = new sezaralgorithm();
txtplain.Text = sezar.decription(txtcipher.Text, Convert.ToChar(cmbKey.Text));
}