Help me understand this code please
1 view (last 30 days)
Show older comments
I do understand the first step so dont explain it. Just need to understand 2nd step line by line where a diffusion key is created using logistic map.
First Step:
r = 3.62;
x(1) = 0.7;
row = size(img,1);
col = size(img,2);
s = row*col;
%Creation of Logistic function
for n=1:s-1
x(n+1) = r*x(n)*(1-x(n));
end
2nd Step:
%Creation of diffusion key
p=3.628;
k(1)=0.632;
for n=1:s-1
k(n+1) = cos(p*acos(k(n)));
end
k = abs(round(k*255));
ktemp = de2bi(k);
ktemp = circshift(ktemp,1);
ktemp = bi2de(ktemp)';
key = bitxor(k,ktemp);
%Ending creation of diffusion key
0 Comments
Answers (1)
KALYAN ACHARJYA
on 13 Jul 2019
Edited: KALYAN ACHARJYA
on 13 Jul 2019
First Step:
r = 3.62; % Define r
x(1) = 0.7; %define array index 1=0.7
row = size(img,1); %Finding row size of img
col = size(img,2); %Finding colm size of img
s = row*col; %s=row*colm
%Creation of Logistic function
for n=1:s-1 % Loop n=1 to s-1
x(n+1) = r*x(n)*(1-x(n)); % First x(2), x(1 is already defined), to find x array
end
2nd Step:
p=3.628; % Define p
k(1)=0.632; %define array k index 1
for n=1:s-1 % Loop n=1 to s-1
k(n+1) = cos(p*acos(k(n))); % First k(2), k(1 is already defined), to find k array
end
k = abs(round(k*255)); % Multiple k with 255, then roundoff, and consider absolute
ktemp = de2bi(k); % decimal to binary k to Ktemp
ktemp = circshift(ktemp,1); % One bit circular shift of K temp
ktemp = bi2de(ktemp)'; % Binary to decimal , replace k temp
key = bitxor(k,ktemp); %key= xor opeartion between k and ktemp
The application, ask the coder who done the code.
2 Comments
Fawad Masood
on 13 Jun 2020
It is simply 1 bit circle shift of element to add confusion in the generated array.
See Also
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!