Мамлакатимизда аxборот-коммуникация



Download 2,18 Mb.
Pdf ko'rish
bet27/28
Sana24.02.2022
Hajmi2,18 Mb.
#232225
1   ...   20   21   22   23   24   25   26   27   28
Bog'liq
El gamal elektron raqamli imzo algoritmiga asoslangan dasturij taminot yaratish


partial
class
Form1

Form 

public
Form1() 

InitializeComponent(); 

OleDbConnection
oldb = 
new
OleDbConnection
(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Sherzod 
aka.mdb"
); 
private
void
label1_Click(
object
sender, 
EventArgs
e) 

Form4
f4 = 
new
Form4
(); 
f4.ShowDialog(); 

public
static
bool
ha = 
false

public
string
index; 
private
void
button1_Click(
object
sender, 
EventArgs
e) 

Form1
f1 = 
new
Form1
(); 
Form2
f2 = 
new
Form2
(); 
Form3
f3 = 
new
Form3
(); 
Form4
f4 = 
new
Form4
(); 
if
(textBox1.Text.Length == 0) 
MessageBox
.Show(
"Loginni 
kiriting"
); 
if
(textBox3.Text.Length == 0) 
MessageBox
.Show(
"parolni 
kiriting"
); 
if
(textBox1.Text.Length != 0 && textBox3.Text.Length != 0) 

OleDbCommand
oldbcommand = 
new
OleDbCommand
(
"Select * from 
table1"
, oldb); 
oldb.Open(); 
OleDbDataReader
oldbreader = oldbcommand.ExecuteReader(); 
double
sads = 
Math
.Pow(2, 30); 
while
(oldbreader.Read()) 

string
username = oldbreader.GetString(5); 
if
(username == heshlash(textBox1.Text)) 

string
password = oldbreader.GetString(6).ToLower(); 
if
(password == heshlash(textBox3.Text)) 

ha = 
true

textBox4.Text = oldbreader.GetString(7); 
textBox5.Text = oldbreader.GetString(8); 
textBox6.Text = oldbreader.GetString(9); 
textBox7.Text = oldbreader.GetString(10); 


92 
string
ismi = oldbreader.GetString(1); 
string
familiyasi = oldbreader.GetString(2); 
string
sharifi = oldbreader.GetString(3); 
string
korxona = oldbreader.GetString(4); 
f2.richTextBox6.Text = ismi + 
" "
+ familiyasi + 
" "
+ sharifi + 
" "
+ korxona; 
f2.label3.Text = textBox4.Text; 
f2.label4.Text = textBox5.Text; 
f2.label9.Text = textBox6.Text; 
f2.label10.Text = textBox7.Text; 
f2.label11.Text = textBox7.Text; 
f2.ShowDialog(); 
break


else 

MessageBox
.Show(
"Parolni noto'g'ri kiritildi"
); 
ha = 
true

break




if
(ha != 
true

MessageBox
.Show(
"Kiritilgan user name bizning bazada 
yo'q"
); 
oldbreader.Close(); 
oldb.Close(); 


public
string
heshlangan; 
public
string
heshlash(
string
soz) 

soz = soz.ToLower(); 
heshlangan = 
""

string
text = 
Convert
.ToString(soz); 
byte
[] dataArray = 
Encoding
.ASCII.GetBytes(text); 
HashAlgorithm
sha = 
new
SHA1CryptoServiceProvider
(); 
byte
[] result = sha.ComputeHash(dataArray); 
for
(
int
i = 0; i < result.Length; i++) 

heshlangan += result[i].ToString(); 

return
heshlangan; 

private
void
Form1_Load(
object
sender, 
EventArgs
e) 

timer1.Start(); 



public
partial
class
Form4

Form 

public
Form4() 

InitializeComponent(); 

OleDbConnection
oldb = 
new
OleDbConnection
(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Sherzod 
aka.mdb"
); 
public
int
button; 
private
void
Form4_Load(
object
sender, 
EventArgs
e) 


93 

timer1.Start(); 
button = 0; 

private
void
timer1_Tick(
object
sender, 
EventArgs
e) 

if
(textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && 
textBox3.Text.Length != 0 && 
textBox4.Text.Length != 0 && textBox5.Text.Length != 0 && 
textBox6.Text.Length != 0) 

button1.Enabled = 
true



private
void
label11_Click(
object
sender, 
EventArgs
e) 


double
q, p, x,y; 
double
d = 3; 
double
n; 
double
Eyler; 
double
R = 
19,a=1,b=1; 
Random
soncha = 
new
Random
(); 
private
void
button1_Click(
object
sender, 
EventArgs
e) 

button++; 
if
(button == 2) 

oldb.Open(); 
OleDbCommand
com = oldb.CreateCommand(); 
com.CommandText = 
"insert into table1( 
ISMI,FAMILIYASI,SHARIFI,KORXONA,LOGIN,PASPORT,OCHIQKALIT,YOPIQKALIT,N,D) 
values(ISMI,FAMILIYASI,SHARIFI,KORXONA,LOGIN,PASPORT,OCHIQKALIT,YOPIQKALIT,N,
D)"

com.Parameters.Add(
"@ISMI"

OleDbType
.VarChar).Value = 
textBox2.Text; 
com.Parameters.Add(
"@FAMILIYASI"

OleDbType
.VarChar).Value = 
textBox1.Text; 
com.Parameters.Add(
"@SHARIFI"

OleDbType
.VarChar).Value = 
textBox3.Text; 
com.Parameters.Add(
"@KORXONA"

OleDbType
.VarChar).Value = 
textBox4.Text; 
com.Parameters.Add(
"@LOGIN"

OleDbType
.VarChar).Value = 
heshlash(textBox5.Text); 
com.Parameters.Add(
"@PASPORT"

OleDbType
.VarChar).Value = 
heshlash(textBox6.Text); 
com.Parameters.Add(
"@OCHIQKALIT"

OleDbType
.VarChar).Value = 
label9.Text; 
com.Parameters.Add(
"@YOPIQKALIT"

OleDbType
.VarChar).Value = 
label11.Text; 
com.Parameters.Add(
"@N"

OleDbType
.VarChar).Value = 
n.ToString(); 
com.Parameters.Add(
"@D"

OleDbType
.VarChar).Value = 
label10.Text; 
com.ExecuteScalar(); 
oldb.Close(); 
this
.Close(); 

int
pu = soncha.Next(100); 
int
qu = soncha.Next(100); 
int
Eu = soncha.Next(100); 
x = sonniTekshir(Eu); 
p = sonniTekshir(pu); 


94 
q = sonniTekshir(qu); 
n = p * q; 
double
eyler=(p-1)*(q-1); 
label9.Text = x.ToString(); 
y = 2; 
for
(; ; ) 

if
((a * x + b * y + R * x * y) % n == 0) 

break


else
{ y++; } 

d = 2; 
for
(; ; ) 

if
((x * d - 1) % eyler == 0) 

break
; } 
else
d++; 

label11.Text = y.ToString(); 
label10.Text = d.ToString(); 
Form1
f1 = 
new
Form1
(); 
textBox1.Enabled = 
false

textBox2.Enabled = 
false

textBox3.Enabled = 
false

textBox4.Enabled = 
false

textBox5.Enabled = 
false

textBox6.Enabled = 
false

this
.ClientSize = 
new
System.Drawing.
Size
(465, 304); 

public
string
heshlangan; 
public
string
heshlash(
string
soz) 

soz = soz.ToLower(); 
heshlangan = 
""

string
text = 
Convert
.ToString(soz); 
byte
[] dataArray = 
Encoding
.ASCII.GetBytes(text); 
HashAlgorithm
sha = 
new
SHA1CryptoServiceProvider
(); 
byte
[] result = sha.ComputeHash(dataArray); 
for
(
int
i = 0; i < result.Length; i++) 

heshlangan += result[i].ToString(); 

return
heshlangan; 

public
int
sonniTekshir(
int
ji) 

Random
tavakkal = 
new
Random
(ji); 
f: 
int
q = tavakkal.Next(200, 2000); 
int
j = 1; 
for
(
int
k = 2; k < q - 1; k++) 

if
(q % k == 0) {j++;} 
if
(j > 1) {
break
;} 

if
(j > 1) {
goto
f;} 
return
q;




95 

public
partial
class
Form2

Form 

public
Form2() 

InitializeComponent(); 
Form1
f1=
new
Form1
(); 
timer1.Start(); 

OleDbConnection
oldb = 
new
OleDbConnection
(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Sherzod 
aka.mdb"
); 
private
void
Form2_Load(
object
sender, 
EventArgs
e) 

Form1
f1=
new
Form1
(); 
OleDbCommand
oldbcommand = 
new
OleDbCommand
(
"Select * from 
table1"
, oldb); 
oldb.Open(); 
OleDbDataReader
oldbreader = oldbcommand.ExecuteReader(); 

private
void
timer1_Tick(
object
sender, 
EventArgs
e) 

if
(richTextBox1.Text.Length != 0) 
button3.Enabled = 
true


private
void
button2_Click(
object
sender, 
EventArgs
e) 

Form3
f3 = 
new
Form3
(); 
f3.label5.Text = label4.Text; 
f3.label2.Text = label9.Text; 
f3.label3.Text = label11.Text; 
f3.richTextBox3.Text = richTextBox4.Text; 
f3.richTextBox2.Text = richTextBox5.Text; 
f3.richTextBox1.Text = richTextBox3.Text; 
f3.ShowDialog(); 

public
string
heshlanganmalumot; 
private
void
button3_Click(
object
sender, 
EventArgs
e) 

heshlanganmalumot=heshla(richTextBox1.Text); 
int
Nninguzunligi=label9.Text.Length; 
richTextBox2.Text = ikkilik(heshlanganmalumot); 
button1.Enabled = 
true


public
long
a, b, R, n,x,y; 
private
void
button1_Click(
object
sender, 
EventArgs
e) 

richTextBox3.Text = 
""

richTextBox4.Text = 
""

richTextBox5.Text = 
""

a = 1; 
b = 1; 
R = 19; 
x = 
Convert
.ToInt64(label3.Text); 
y=
Convert
.ToInt64(label4.Text); 
n = 
Convert
.ToInt64(label9.Text); 
string
parametrlimatn = parametrik(a, b, R, n, x, 
heshlanganmalumot.Substring(0,4)); 
richTextBox4.Text = shifrlash(richTextBox1.Text, n, x); 
richTextBox5.Text = shifrlash(richTextBox6.Text, n, x); 


96 
richTextBox3.Text = (parametrlimatn); 
button2.Enabled = 
true


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
shifrlash(
string
matn,
long
N,
long
x) 

long
daraja, qoldiq = 1;
string
shifrmatn=
""

for
(
int
i = 0; i < matn.Length; i++) 

long
soni = 
Convert
.ToChar(matn[i]); 
for
(
int
j = 1; j <= x; j++) 

daraja = qoldiq * soni; 
qoldiq = daraja % N; 

string
raqam = qoldiq.ToString(); 
int
l = 0; 
for
(
int
s = 0; s < N.ToString().Length; s++) 

if
(raqam.Length + l == N.ToString().Length) 
{ shifrmatn += qoldiq.ToString(); 
break
; } 
else 
{ shifrmatn += 
"0"
; l++; } 

qoldiq = 1; 

return
shifrmatn; 

public
string
shifrlash1(
string
matn, 
long
N, 
long
x) 

long
daraja, qoldiq = 1; 
string
shifrmatn = 
""

long
soni = 
Convert
.ToInt64(matn); 
for
(
int
j = 1; j <= x; j++) 

daraja = qoldiq * soni; 
qoldiq = daraja % N; 

shifrmatn = qoldiq.ToString(); 
return
shifrmatn; 

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); 
}



97 
for
(
int
i = 0; i < srt.Length; i++) 

if
(srt[i] == 
'0'

str1 += 
"1"

else
str1 += 
"0"


return
str1; 

public int paraR(int f1, int f2) 

int para = (a*f1 + b*f2 + R * f1*f2) % n; 
return para; 

public
string
heshla(
string
soz) 

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(); 

return
soz; 

private
void
groupBox2_Enter(
object
sender, 
EventArgs
e) 


private
void
groupBox6_Enter(
object
sender, 
EventArgs
e) 



public
Download 2,18 Mb.

Do'stlaringiz bilan baham:
1   ...   20   21   22   23   24   25   26   27   28




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish