⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsa.m

📁 Contains Rsa and program for magnification of a small image.
💻 M
字号:
clc; 
clear;
a=primes(10);
p=a(length(a));
q=a(length(a)-1);

n=p*q;
z=(p-1)*(q-1);
d=2;
while(GCD(d,z)~=1)
        d=d+1;
end;
e=2;
while(mod(d*e,z)~=1)
         e=e+1;
end;
x=input('Enter the Message to be Encrypted : ','s');
disp(sprintf('\n'));
for i=1:length(x)
      if((x(i)>=97))
           t(i)=double(x(i))-96;       
           txt(i)=mod(power(t(i),e),n);
           rxd(i)=mod(power(txt(i),d),n);
          dnc(i)=char(rxd(i)+96);
     else 
          if((x(i)>=65)&(x(i)<=96))
                t(i)=double(x(i))-65;       
                txt(i)=mod(power(t(i),e),n);
                rxd(i)=mod(power(txt(i),d),n);
                dnc(i)=char(rxd(i)+65);
          end;
          if((x(i)>10)&(x(i)<=64))
               t(i)=double(x(i))-32;
               txt(i)=mod(power(t(i),e),n);
               rxd(i)=mod(power(txt(i),d),n);
               dnc(i)=char(rxd(i)+32);
          end;
      end;
end;
disp(sprintf('Encrypted Message  :\n'));
disp(txt);
disp(sprintf('\nDecrypted Message  : %s',dnc));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -