where my code is wrong

조회 수: 7 (최근 30일)
rjnt Kaur
rjnt Kaur 2013년 5월 12일
hello professionals can you plz help me in this code i want to display a at decrypted part but there is no value .plz help in code where i am wrong ...mostly the value of c3 come in form of 4.1038e+216...according to me if c(3) be made interger then code will be ok...but how it can be....as my code is
|matlab code for cryptography:|
% % %Encryption
for j=1:x
c1(j)=l_mod(c(j),e,n);
c3=g.^c1(j);
t=m*m;
c2=l_mod(r,m,t);
cipher(j)=c3*c2;
end
disp('Cipher Text of the entered Message:');
disp(cipher);
% % %Decryption
for j=1:x
m1(j)=l_mod(cipher(j),lamda,t);
m2(j)=m1(j)-1;
m3(j)=m2(j)/m;
m4=l_mod(mew,1,m);
m5=m3(j )*m4;
msg(j)=l_mod(m5,d,n)
end
disp('Decrypted Message is')
dec=char(msg)
|answer coming after running code:|
The value of (n) is: 391
The public key (e) is: 3
The value of (g) is: 552
The private key (m)is: 551
Enter the message: a
ASCII Code of the entered Message:
97
c1 =
79
c3 =
4.1038e+216
t =
303601
c2 =
141151
cipher =
5.7926e+221
Cipher Text of the entered Message:
5.7926e+221
msg =
15.9049
Decrypted Message is
dec =

답변 (4개)

Matt J
Matt J 2013년 5월 12일
편집: Matt J 2013년 5월 12일
It appears to be l_mod's fault. Where does l_mod come from? What does it do, and what makes you sure that it is working?

rjnt Kaur
rjnt Kaur 2013년 5월 12일
l_mod is mfile for cryptography without this mod cannot be calculated ...because i am doing this for example c^e mod m
  댓글 수: 3
rjnt Kaur
rjnt Kaur 2013년 5월 13일
Ok ...can you please tell me wat be the matlab code for equation c^e mod n
Bjorn Gustavsson
Bjorn Gustavsson 2013년 5월 13일
c.^mod(e,n)

댓글을 달려면 로그인하십시오.


rjnt Kaur
rjnt Kaur 2013년 5월 12일
l_mod is m file for module...for example i have to calculate c^e mod f then mod(c,e,m) is calculated using m file of mod

rjnt Kaur
rjnt Kaur 2013년 5월 12일
i want to display a which has char value 97 but at output side it doesnot come 97
  댓글 수: 1
Image Analyst
Image Analyst 2013년 5월 12일
Please add comments to someone's answer, and edit them if you want to add stuff, rather than adding additional, new "Answers", which actually aren't answers at all.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by