Sezer shifri: c# da forma oynasi yaratamiz Sezer shifri


Download 182.76 Kb.
Sana21.06.2023
Hajmi182.76 Kb.
#1641517
Bog'liq
Sezer shifri c# da forma oynasi yaratamiz-fayllar.org


Sezer shifri: c# da forma oynasi yaratamiz

Sezer shifri:


1.c# da forma oynasi yaratamiz



2.keyin esa yangi sinf hosil qilamiz va uni transposition dab ataymiz
Hosil qilingan sinf ko’rinishi:
/*
* Создано в SharpDevelop.

* Пользователь: G'olibbek


* Дата: 21.12.2019
* Время: 14:33
*
* Для изменения этого шаблона используйте меню "Инструменты | Параметры | Кодирование | Стандартные заголовки".
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sezer_shifri
{

class transposition


{
private int[] key=null;
public void setkey(int[] _key)
{
key=new int[_key.Length];
for(int i=0;i<key.Length;i++)
key[i]=_key[i];
}
public void setkey(string[] _key)
{
key=new int[_key.Length];
for(int i=0;i<key.Length;i++)
key[i]=Convert.ToInt32(_key[i]);
}
public void setkey(string _key)
{
string[] keyMass=_key.Split(' ');
setkey(keyMass);
}
public string Encrypt(string input)
{
for(int i=0;i input+=input[i];
string result=" ";
for(int i=0;ikey.Length)
{
char[] transposition=new char[key.Length];

for(int j=0;j<key.Length;j++)
transposition[key[j]-1]=input[i+j];
for(int j=0;j<key.Length;j++)
result+=transposition[j];
}
return result;
}
public string Decrypt(string input)
{
string result=" ";
for(int i=0;ikey.Length)
{
char[] transposition=new char[key.Length];

for(int j=0;j<key.Length;j++)
transposition[j]=input[i+key[j]-1];
for(int j=0;j<key.Length;j++)
result+=transposition[j];
}
return result;
}

}
}


3.forma oynasiga o’tib quyidagilarni qo’shamiz:
1)textbox- 3ta;
2)label- 3ta;
3)button;
4)groupbox;
5)radiobutton- 2ta;
4.boshlash tugmasini 2 marta chertib quyidagilarni kiritamiz:


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace sezer_shifri
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
transposition t;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();

// TODO: Add constructor code after the InitializeComponent() call.


//
t=new transposition();
}
void StartButtonClick(object sender, EventArgs e)
{

t.setkey(keyTextBox.Text);
if(encryptRadioButton.Checked)
outputTextBox.Text=t.Encrypt(inputTextBox.Text);
else
outputTextBox.Text=t.Decrypt(inputTextBox.Text);
}

}
}



programmani sinab ko’ramiz.
http://fayllar.org
Download 182.76 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling