partial
class
Form3
:
Form
{
public
Form3()
{
InitializeComponent();
Form2
f2=
new
Form2
();
richTextBox1.Text = f2.richTextBox3.Text;
}
OleDbConnection
oldb =
new
OleDbConnection
(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Sherzod
aka.mdb"
);
public
long
y,a,b,n,R,D;
private
void
button1_Click(
object
sender,
EventArgs
e)
{
richTextBox4.Text =
""
;
richTextBox5.Text =
""
;
richTextBox6.Text =
""
;
a = 1;
b = 1;
R = 19;
y =
Convert
.ToInt64(label5.Text);
D =
Convert
.ToInt64(label3.Text);
n =
Convert
.ToInt64(label2.Text);
richTextBox4.Text = deshifrlash(richTextBox3.Text, D, n);
richTextBox5.Text = deshifrlash(richTextBox2.Text, D, n);
98
richTextBox6.Text = parametrik(1, 1, 19, n, y,
richTextBox1.Text);
}
public
string
parametrik(
long
a,
long
b,
long
R,
long
n,
long
kalit,
string
matn)
{
long
matn1 =
Convert
.ToInt64(matn);
string
shifr =
Convert
.ToString((matn1 * a + kalit * b + R *
matn1 * kalit) % n);
return
shifr;
}
public
string
natija =
""
;
public
string
deshifrlash(
string
matn,
long
D,
long
n)
{
int
g=0;
string
yoz=
""
;
double
[] massiv =
new
double
[matn.Length /n.ToString().Length];
for
(
int
y=0;y{
yoz+=matn[y];
if
(yoz.Length == n.ToString().Length)
{
massiv[g] =
Convert
.ToDouble(yoz);
yoz =
""
;
g++;
}
}
double
daraja;
double
qoldiq = 1;
string
natija =
""
;
for
(
int
i = 0; i {
for
(
int
j = 1; j <= D; j++)
{
daraja = qoldiq * massiv[i];
qoldiq = daraja % n;
}
string
sanash
=
Convert
.ToChar(
Convert
.ToInt32(qoldiq)).ToString();
natija+= sanash;
qoldiq = 1;
}
return
natija;
}
string
ikkilik(
string
plain_text)
{
string
srt =
""
;
string
str1 =
""
;
int
plantextuzunligi = plain_text.Length;
for
(
int
i = 0; i < plantextuzunligi; i++)
{
int
charCode =
Convert
.ToInt32(plain_text[i]);
int
k2;
for
(
int
j = 7; j >= 0; j--)
{
k2 = (charCode >> j) & 1;
srt +=
Convert
.ToString(k2);
}
}
for
(
int
i = 0; i < srt.Length; i++)
{
if
(srt[i] ==
'0'
)
99
str1 +=
"1"
;
else
str1 +=
"0"
;
}
return
str1;
}
private
void
richTextBox6_TextChanged(
object
sender,
EventArgs
e)
{
}
private
void
button2_Click(
object
sender,
EventArgs
e)
{
string
soz = richTextBox4.Text;
byte
[] dataArray =
Encoding
.ASCII.GetBytes(soz);
HashAlgorithm
sha =
new
SHA1CryptoServiceProvider
();
byte
[] result = sha.ComputeHash(dataArray);
soz =
""
;
for
(
int
i = 0; i < result.Length; i++)
{
soz+= result[i].ToString();
}
string
ii = richTextBox6.Text;
if
(richTextBox6.Text == soz.Substring(0, 4)) { label1.Visible =
true
; richTextBox6.Text = ii +
" "
+ soz.Substring(0, 4); }
else
{ label1.Visible =
true
; label1.Text =
"Imzo haqiqiy emas"
;
richTextBox6.Text = ii +
" "
+ soz.Substring(0, 4); }
richTextBox6.Text =
""
;
}
}
Do'stlaringiz bilan baham: |