?? decrypt_vigenere.m
字號:
%% Coincidence Counting Programclose all;clear all;clc;%% Read the cyphered text from a *.txt filetext_input = loadtext('Decrypt_3.txt');%% Remove the blanks from input text.index = find(text_input ~= ' ');text = text_input(index);%% len = length(text);shmax = len-1;count=0;results = zeros(shmax,3);for m=1:shmax % Rotate text relative to itself by m spots teststr=[text(m+1:end) text(1:m)]; % Count number of matches for i=1:len if teststr(i)==text(i) count=count+1; end end results(m,1) = m; results(m,2) = count; % Normalize the count by the length of the string results(m,3) = count/len; % Reset count for next iteration count=0;end% What does this do? Try to make sense of it!resultsmax_m=find(max(results(:,3))==results(:,3))max_norm_count=max(results(:,3))f=find(results(:,2)>19);results(f,:)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -