Xabar
|
A
|
B
|
C
|
D
|
E
|
F
|
G
|
H
|
I
|
J
|
K
|
L
|
M
|
N
|
O
|
P
|
Q
|
R
|
S
|
T
|
U
|
V
|
W
|
X
|
Y
|
Z
|
x
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
(3x+4)mod26
|
4
|
7
|
10
|
13
|
16
|
19
|
22
|
25
|
2
|
5
|
8
|
11
|
14
|
17
|
20
|
23
|
0
|
3
|
6
|
9
|
12
|
15
|
18
|
21
|
24
|
1
|
Shifr matn
|
E
|
H
|
K
|
N
|
Q
|
T
|
W
|
Z
|
C
|
F
|
I
|
L
|
O
|
R
|
U
|
X
|
A
|
D
|
G
|
J
|
M
|
P
|
S
|
V
|
Y
|
B
|
Algoritmni c# tilidagi kodini keltirib o’tamiz.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Affin_sezar_usuli
{
public partial class Form1 : Form
{
public Form1()
{
//richTextBox2.Enabled = false;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int key = int.Parse(textBox1.Text); // shifr=key*matn+b;
int n = key % 256;
string matn = richTextBox1.Text;
int k = matn.Length;
int b = 53;
int[] shifr= new int[k];
int[] d = new int[k];
for (int i = 0; i < k; i++)
{
d[i] = (int)matn[i];
}
for (int i = 0; i < k; i++)
{
shifr[i] = (d[i] * key + b + n * 256) % 256;
}
string soz = "";
for (int i = 0; i < k; i++)
{
soz = soz + Convert.ToString(((char)shifr[i]));
}
richTextBox2.Text = soz;
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
int a;
private void button2_Click(object sender, EventArgs e)
{
int key = int.Parse(textBox1.Text);
int n = key % 256;
//kalitga teskari sonni topish;
////////////////////////
int r1, r2, r, t1, t2, t, q;
int l = 256;
r1 = l; r2 = key;
t1 = 0; t2 = 1; // initalizatsiya
while (r2 > 0)
{
q = r1 / r2;// r ni aniqlash
r = r1 - q * r2;
r1 = r2;
r2 = r;
///////////////////// t ni aniqlash;
t = t1 - t2 * q;
t1 = t2; t2 = t;
}
// tublikka tekshirish
if (r1 == 1)
{
if (t1 > 0)
{
a = t1;
}
else
{
a = l + t1;
} }
else
{
MessageBox.Show("berilgan maydonda ko'rsatilgan kalitga teskari son mavjud emas");
}
label4.Text = label4.Text + Convert.ToString(a);
//int j = Convert.ToInt64(a);
//////////////////////////////////
string matn1 = richTextBox2.Text;
int k = matn1.Length;
int b = 53;
int[] deshifr = new int[k]; // deshifr=(shifr-b)key(-1)%256
int[] d1 = new int[k];
for (int i = 0; i < k; i++)
{
d1[i] = (int)matn1[i];
}
for (int i = 0; i < k; i++)
{
deshifr[i] = ((d1[i] - b) * a + n * 256) % 256;
}
string soz = "";
for (int i = 0; i < k; i++)
{
soz = soz + Convert.ToString(((char)deshifr[i]));
}
richTextBox1.Clear();
richTextBox1.Text = "\n"+ soz;
} }
Ishni bajarilish tartibi va qo‘yilgan vazifa
Asosiy matn shifrlash usullaridan birida shifrlansin va qadamma – qadam izohlansin. Shuningdek Delpi, Java, S++ va C# dasturlash tizimlaridan birida dasturiy ta’minot yaratilsin.
Izoh. Dasturiy ta’minotni ishlab chiqishda talaba tomonidan ixtiyoriy dasturlash tili olinishi mumkin va hisobotda dasturiy ta’minot ishlashi to‘liq tavsiflansin.
Hisobot tarkibi
Hisobot quyidagi ma’lumotlardan tarkib topgan bo‘lishi lozim:
Nazariy qismda keltirilgan algoritmning dasturiy ta’minotidan foydalanish jarayonidagi olingan rasmlari va ularga izoh.
Yaratilgan dasturiy ta’minotning dasturiy kodi.
Nazorat savollari
O‘rin almashtirish shifrlarining umumiy mohiyati keltiring.
O‘rniga qo‘yish shifrlarining umumiy mohiyati keltiring.
Do'stlaringiz bilan baham: |