1 function eimg =encryptionprocess(img,h,RK,SubBytes,Pbox,r)
\r
2 %%%%%%%%%%%%%% convert image to a vector seq
\r
3 %seq=double(reshape(img,1,[]));
\r
4 seq_bin=double(byte2bit(uint8(img))) ;
\r
5 encr_seq_binary=zeros(1,length(seq_bin));
\r
6 %%%%%%%%%%%%%%%%%%%% calculate the number of blocks%%%%%%%%%%%%%%%%%%%%%%%%
\r
7 nb= floor(length(seq_bin)/(8*h));
\r
8 RK_bin=double(reshape(byte2bit(RK),r,[]));
\r
9 Bin_Sbox =double((Convert_Sbox_Bin(SubBytes)));
\r
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
11 %%%%%%%%%%%%%%%%%%%% Applied the confusion process then the bits permutation for r rounds
\r
13 temp=seq_bin((it-1)*8*h+1:it*8*h);
\r
15 temp=bitxor(temp,RK_bin(itr,1:h*8));
\r
16 temp= (reshape(Bin_Sbox (double(bit2byte(temp))+1,:)',1,[]));
\r
19 encr_seq_binary((it-1)*8*h+1:it*h*8)=temp;
\r
22 % Convert to Byte representation
\r
24 %valbin=reshape(valbin,Tb/8,8);
\r
25 eimg=(bit2byte( encr_seq_binary));