Guruh talabasi Bajardi: Fayzullayev Ruslan Tekshirdi: Tojiakbarova Umida


Download 0.62 Mb.
Sana17.06.2023
Hajmi0.62 Mb.
#1537707
Bog'liq
1680354703 (2)


OʻZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XOZAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI


KRIPTOGRAFIYA 2
2-AMALIY MASHG’ULOT
712-20 guruh talabasi
Bajardi:Fayzullayev Ruslan
Tekshirdi:Tojiakbarova Umida

TOSHKENT – 2023


8-variant
1.El-gamali



Dastur kodi:


p = int(input('p='))


x = int(input('x='))
k = int(input('k='))

g = 0
for i in range(2, p):


gst = set()
for j in range(1, p):
r = pow(i, j, p)
if r in gst:
break
gst.add(r)
else:
g = i
break
a = pow(g, x, p)
b = pow(g, k, p)
print('g =', g, ',a =', a, ',b =', b)

def encrypt(d):


return (d * pow(a, k, p)) % p

def decrypt(c):


return (c * pow(b, p - x - 1, p)) % p
s = int(input('Ochiqmatn: m='))
c = encrypt(s)
d = decrypt(c)
print('Shifrmatn: c =', c)
print('Deshifrmatn: d =', d)





2.Deshifrlash amali





Download 0.62 Mb.

Do'stlaringiz bilan baham:




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