clc;
clear;


ix=imread('crypt.jpg');
ix=rgb2gray(ix);
im=double(ix);
iln=size(im,1);
jln=size(im,2);

key=3000;

%% Enkripsi 

cipher=[];
y=[];
for i=1:iln
for j=1:jln
    m= im(i,j)+key; 
    x=mod(m,256);
    y=[y x];
    
end
cipher=[cipher;y];
y=[];
end
cipherx=uint8(cipher);


%% ===== Dekripsi

plain=[];
y=[];
for i=1:iln
for j=1:jln
    m= cipher(i,j)-key; 
    x=mod(m,256);
    y=[y x];
    
end
plain=[plain;y];
y=[];
end
plainx=uint8(plain);
