• Eyler funksiyasi m ni aniqlaymiz.
  • {t} sonlar to„plamidan tasodifiy d-DESHIFRLASH kaliti tanlanadi
  • Ochiq matn shifrLASH JARAYONI
  • RSA tizimi bo„yicha loyiha keyslarini yaratish va talabalar bilimini tekshirish usullari




    Download 4,2 Mb.
    bet44/96
    Sana30.07.2024
    Hajmi4,2 Mb.
    #268923
    1   ...   40   41   42   43   44   45   46   47   ...   96
    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)


    # {t} sonlar to„plamidan tasodifiy d-DESHIFRLASH kaliti tanlanadi


    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)


    #Ochiq matn shifrLASH JARAYONI


    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)

    Download 4,2 Mb.
    1   ...   40   41   42   43   44   45   46   47   ...   96




    Download 4,2 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    RSA tizimi bo„yicha loyiha keyslarini yaratish va talabalar bilimini tekshirish usullari

    Download 4,2 Mb.