|
RSA tizimi bo„yicha loyiha keyslarini yaratish va talabalar bilimini tekshirish usullari
|
bet | 44/96 | Sana | 30.07.2024 | Hajmi | 4,2 Mb. | | #268923 |
Bog'liq Axborot xavfsizligi 2022 (1) RSA tizimi bo„yicha loyiha keyslarini yaratish va talabalar bilimini tekshirish usullari.
Ishdan maqsad: RSA shifrlash algoritmi ishlash prinsipini o‗rganish va uning dasturlash tillarida loyihalash.
RSA kriptografik algoritimning python dasturlash tilida yozilgan dasturi:
#1-Qadam. RSA shifrlash algoritmi uchun 200 dan kam bo„lmaga p va q sonlarini kiriting!
print('p tub son kiriting! p:=') p=int(input())
print('q tub son kiriting! q:=') q=int(input())
# n ni aniqlaymiz n=p*q print('n=',n)
#3-Qadam
#Eyler funksiyasi m ni aniqlaymiz.
m=(p-1)*(q-1)
print('m=',m)
#4-Qadam
# m bilan o„zoro tub bo„lgan {t} sonlar to„plami aniqlanadi
t=[]
for i in range (1,m+1): k=0
for j in range (1,i+1): if i%j==0:
k=k+1 if k==2:
if m%i!=0: t.append(i)
print("d=",t)
import random d=random.choice(t)
print("Deifrlash kaliti tanlanadi(d;n):=",d,";",n)
#5-Qadam
# (e*d mod m=1) tenglamadan e-SHIFRLASH kaliti topiladi
e=1
while (e*d%m!=1)or(e==d): e=e+1
print("Sifrlash kaliti (e;n):=",e,";",n)
shifrmatn=[]
s=input("Ochiq matn kiriting:") s1="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
l=len(s)
for t in range (0,l):
x = s1.index(s[t])+1 y=x**e%n shifrmatn.append(y) print(x," ",end="")
print("shifrmatn:",shifrmatn)
#DESHIFRLASH JARAYONI
deshifrmatn=[] s=shifrmatn l=len(s)
for t in range (0,l): y=int(s[t])**d%n deshifrmatn.append(y)
print("deshifrmatn:",deshifrmatn)
|
| |