📄 desordtext.m
字号:
function desordtext(F,y)
%------------------------------------------------------------------------------------------
% DESORDTEXT
%
% The following program disorders a text file transforming it into a matrix.
%
% and disordering for lines and columns and then he it transform it into a vector.
%
% Author: Francisco Echegorri
% E-mail: fdefac@montevideo.com.uy
% Created in September of 2002.
%------------------------------------------------------------------------------------------
% El siguiente programa desordena un archivo de texto convirtiendolo en una matrix
% y desordenando por filas y columnas para luego convertirlo en un vector.
%------------------------------------------------------------------------------------------
if nargin==0
x=input('Enter a password (of up to 24 letters)\n','s');
[y, pathname] = uigetfile('*.*', 'Select the Text File ');
buffer=pwd;
cd (pathname);
cd (buffer);fid=fopen(y,'rt');F=fread(fid);F=char(F)';
else x=input('Enter a password (of up to 24 letters)\n','s');
end
clc,n=length(F);
x=dalfa(x);x=keyexpansion(x);
m=fix(sqrt(n)); %It calculates the side of the matrix.
for i=1:m
X(i,1:m)=F(1:m);lon=length(F);F=F(m+1:lon);%It orders the numbers in a square matrix.
end
p=m+1;long=length(F);
while long>=m
X(p,1:m)=F(1:m);lon=length(F);F=F(m+1:lon);p=p+1;long=length(F);
end
X(p,1:long)=F(1:long);X(p,long+1:m)=255;%Those that they lack are completed with 255.
MC=size(X(1,:));MF=size(X(:,1));NC=MC(1,2);NF=MF(1,1);w=x.*997;x=w-fix(w);
y=randpermut(x,NF);z=randpermut(x,NC);
for i=1:NF
Y(i,:)=X(y(i),:);%It disorders for lines.
end
for j=1:NC
Z(:,j)=Y(:,z(j));%It disorders for columns.
end
F=[];
for i=1:NF
a=Z(i,1:NC);F=[F,a]; %It transforms it into a vector.
end
save htext F %He stays in format mat in htext.
load htext,u=char(F);
disp(' ')
disp('The crypt text is in htext:')
disp(' ')
disp(u)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -