function eimg =encryptionprocess(img,h,RK,SubBytes,Pbox,r)
%%%%%%%%%%%%%% convert image to a vector seq
%seq=double(reshape(img,1,[]));
seq_bin=double(byte2bit(uint8(img))) ;
encr_seq_binary=zeros(1,length(seq_bin));
%%%%%%%%%%%%%%%%%%%% calculate the number of blocks%%%%%%%%%%%%%%%%%%%%%%%%
nb= floor(length(seq_bin)/(8*h));
RK_bin=double(reshape(byte2bit(RK),r,[]));
Bin_Sbox  =double((Convert_Sbox_Bin(SubBytes)));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% Applied the confusion process then the bits permutation for r rounds
for it=1:nb
      temp=seq_bin((it-1)*8*h+1:it*8*h);
    for itr=1:r
        temp=bitxor(temp,RK_bin(itr,1:h*8));    
        temp= (reshape(Bin_Sbox (double(bit2byte(temp))+1,:)',1,[]));
        temp= temp(Pbox);
    end
    encr_seq_binary((it-1)*8*h+1:it*h*8)=temp;
end

% Convert to Byte representation

%valbin=reshape(valbin,Tb/8,8);
eimg=(bit2byte(  encr_seq_binary));