]> AND Private Git Repository - Cipher_code.git/blob - Chaotic_code/decryptionprocess2.m
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
[Cipher_code.git] / Chaotic_code / decryptionprocess2.m
1 function dimg =decryptionprocess(img,h,RK,Inv_SubBytes,Inv_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 decr_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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
10 %%%%%%%%%%% Convert S-box to binary representation to avoid repeat the\r
11 %%%%%%%%%%% byte2bit conversion\r
12 Bin_Sbox  =double(Convert_Sbox_Bin(Inv_SubBytes));\r
13 %%%%%%%%%%%%%%%%%%%% Applied the confusion process (r rounds)\r
14 for it=1:nb\r
15      temp=seq_bin((it-1)*8*h+1:it*h*8);\r
16     for itr=r:-1:1       \r
17         temp= temp(Inv_Pbox);\r
18         temp=reshape(Bin_Sbox (double(bit2byte(temp))+1,:)',1,[]);\r
19        % double(byte2bit(Inv_SubBytes(double(bit2byte(temp))+1)));\r
20         %\r
21 %         size(temp)\r
22         %byte2bit(Inv_SubBytes(double(bit2byte(temp))+1));\r
23         %temp= Inv_SubBytes(temp+1);\r
24         temp=bitxor(temp,RK_bin(itr,1:h*8));   \r
25     end\r
26     decr_seq_binary((it-1)*8*h+1:it*h*8)=temp;\r
27 end\r
28 \r
29 % Convert to Byte representation\r
30 \r
31 %valbin=reshape(valbin,Tb/8,8);\r
32 dimg=uint8(bit2byte(decr_seq_binary));