title: #DESHIFRLASH JARAYONI - O„zbekiston respublikаsi oliy vа o„rtа mаxsus tа‟lim vаzirligi buxoro davlat universiteti...
text: 69
  l=len(s)
  print("Matn uzunligi:",l)
  #1-Qadam
  print('p tub son kiriting! p:=')
  p=int(input())
  print('q tub son kiriting! q:=')
  q=int(input())
  #2-Qadam
  # n ni aniqlaymiz
  n=p*q
  print('n=',n)
  #3-Qadam
  #Eyler formulasidan 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
  70
  e=1
  while (e*d%m!=1)or(e==d):
  e=e+1
  print("Sifrlash kaliti (e;n):=",e,";",n)
  #Ochiq matn shifrLASH JARAYONI
  index=[]
  shifrmatn=[]
  shifrmatn2=""
  for t in range (0,l):
  x = ord(s[t])
  index.append(x)
  y=x**e%n
  shifrmatn.append(y)
  shifrmatn2+=bin(y)
  print("index:",index)
  print("shifrmatn:",shifrmatn)
  print("shifrmatn2:",shifrmatn2)
  print("Shifrlash muofoqiyatli bajarildi!!!")