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
Do'stlaringiz bilan baham: |