MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] rsa加密解密数据过大 (https://www.labfans.com/bbs/showthread.php?t=20618)

月球那半边 2014-01-06 00:12

rsa加密解密数据过大
 
实验要求做一个rsa加密解密的matlab程序,
p=3;
q=11;
e=7;
n=p*q;
a=(p-1)*(q-1);
for i=1:a+1 %计算d
b=mod(e*i,a);
if b==1
d=i;
disp(d)
else
i=i+1;
end
end
A=load('D:\1.txt');
B=power(A,e)
C=mod(B,n)
D=power(C,d)
E=mod(D,n)
disp('public key:')
disp([n,e])
disp('private key:')
disp([n,d])
disp('cipher text is :')
disp(C)
disp('deciphered text is :')
disp(E)
这是我自己写的,对于小数据能运行,但是大数据就出问题,应该怎么改啊请问。
message(1.txt)为5566 7788 123 98765 739 1111 19 705 1209 1116
p = 9973, q = 997, e =10243
加密后应该为526459 8464775 2559950 8368498 1743494 7767529 2889668 8913214 8050998 8129974
谢谢了


所有时间均为北京时间。现在的时间是 18:08

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.