Caesar cipher matlab code
조회 수: 28 (최근 30일)
이전 댓글 표시
Can anyone write a very basic code for caesar cipher that shifts input characters by 5 place?
댓글 수: 1
James Tursa
2022년 8월 25일
What have you done so far? What specific problems are you having with your code?
채택된 답변
Md. Atiqur Rahman
2022년 8월 27일
편집: Walter Roberson
2022년 8월 28일
댓글 수: 10
Walter Roberson
2022년 8월 31일
Output(i) = char(Output(i));
Why are you doing that redundant operation? Yes, you convert to char but you store it in the same array so it would convert back to the same data type.
Output(Output<=58)=32;
Why are you mixing logical indexing of the entire array inside a loop?
추가 답변 (1개)
Walter Roberson
2022년 8월 25일
cc5('HELLO')
cc5('ABCXYZ')
function out = cc5(in)
TT('A':'Z') = ['F':'Z', 'A':'E'];
out = TT(in);
end
댓글 수: 2
Walter Roberson
2022년 8월 27일
Your Plaintext is a vector of characters. Plaintext+Shift <= 90 would be a vector. When you if a vector, the result is considered true only if all of the values in the vector are non-zero. So your Plaintext+Shift <= 90 test would be true only if all of the characters where no more than 'U'
You should investigate logical indexing.
참고 항목
카테고리
Help Center 및 File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!