간단한 대체 암호를 만들려고 시도했지만 내 프로그램은 제대로 작동하지만 숫자를 암호화하거나 해독하지 않습니다. 난 정말 내 코드에 추가해야 그래서 그것이 제대로 작동하는지 모르겠다 ... 어떤 아이디어 ??? 이 명시 적으로 만 대문자와 소문자를 암호화 할 말을하는지 지금까지 내가 말할 수있는 내 코드간단한 대체 암호를 사용하여 암호화 및 암호 해독
namespace yaba
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEncrypt_Click(object sender, EventArgs e)
{
string encrypt = tboxIO.Text;
encrypt.ToLower();
bool tbNull = tboxIO.Text == "";
if (tbNull)
MessageBox.Show("There is nothing to encrypt.");
else
{
char[] array = encrypt.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
int num = (int)array[i];
if (num >= 'a' && num <= 'z')
{
num += Convert.ToInt32(tbShift.Text);
if (num > 'z')
{
num = num - 26;
}
}
else if (num >= 'A' && num <= 'Z')
{
num += Convert.ToInt32(tbShift.Text);
if (num > 'Z')
{
num = num - 26;
}
}
array[i] = (char)num;
}
lblIO.Text = "Encrypted Message";
tboxIO.Text = new string(array).ToLower();
}
tboxIO.Copy();
}
private void btnDecrypt_Click(object sender, EventArgs e)
{
string decrypt = tboxIO.Text;
decrypt.ToLower();
bool tbNull = tboxIO.Text == "";
if (tbNull)
MessageBox.Show("There is nothing to decrypt.");
else
{
char[] array = decrypt.ToCharArray();
for (int i = 0; i < array.Length; i++)
{
int num = (int)array[i];
if (num >= 'a' && num <= 'z')
{
num -= Convert.ToInt32(tbShift.Text);
if (num > 'z')
num = num - 26;
if (num < 'a')
num = num + 26;
}
else if (num >= 'A' && num <= 'Z')
{
num -= Convert.ToInt32(tbShift.Text);
if (num > 'Z')
num = num - 26;
if (num < 'A')
num = num + 26;
}
array[i] = (char)num;
}
lblIO.Text = "Decrypted Message";
tboxIO.Text = new string(array).ToUpper();
}
tboxIO.Copy();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
MessageBox.Show("hehe");
}
private void tboxIO_MouseClick(object sender, MouseEventArgs e)
{
tboxIO.SelectAll();
tboxIO.Copy();
}
private void tbShift_MouseClick(object sender, MouseEventArgs e)
{
tbShift.SelectAll();
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}