Caesar cipher matlab code
50 次查看(过去 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!