one time pad plus randstream
古いコメントを表示
Hello Guys,
I need help for this question asap.
Implement a version of the character based One-Time Pad, that utilizes a random number generator chosen through RandStream.
clc;
clear all;
close all;
alph=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
b1=0:25;
keyword='famt';
code='ratn';
disp(keyword);
disp(code);
for ii=1:length(keyword)
for jj=1:length(alph)
if keyword(ii)==alph(jj)
w1(ii)=b1(jj);
end
if code(ii)==alph(jj)
c1(ii)=b1(jj);
end
end
end
ncode=w1+c1;
for ii=1:length(ncode)
if(ncode(ii)>25)
ncode(ii)=ncode(ii)-26;
else
continue
end
end
display(ncode);
for ii=1:length(ncode)
for jj=1:length(b1)
if ncode(ii)==b1(jj)
finalcode(ii)=alph(jj);
else
continue
end
end
end
disp(finalcode);
7 件のコメント
the cyclist
2023 年 1 月 20 日
Your code runs to completion with no errors or warnings. So, what is your question exactly?
Mi
2023 年 1 月 20 日
Mathieu NOE
2023 年 1 月 20 日
I don't know where you intend to introduce the random effect in this algorithm, so this comment may not be relevant. However, the algorithm as currently implemented can be simplified as follows:
keyword='famt';
code='ratn';
w1 = double(keyword - 'a');
c1 = double(code - 'a');
ncode = mod(w1+c1, 26)
finalcode = char(ncode + 'a')
Mi
2023 年 1 月 20 日
Les Beckham
2023 年 1 月 20 日
You need to get clarification on what portion of the algorithm is supposed to be randomized. Perhaps the code string is supposed to be randomly generated? Until that is clarified, there isn't really anything else we can do to help with this.
Mi
2023 年 1 月 20 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!