Lampiran 1. Fungsi Utama
function varargout = UTAMA(varargin) % UTAMA M-file for UTAMA.fig
% UTAMA, by itself, creates a new UTAMA or raises the existing
% singleton*. %
% H = UTAMA returns the handle to a new UTAMA or the handle to
% the existing singleton*. %
% UTAMA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UTAMA.M with the given input arguments.
%
% UTAMA('Property','Value',...) creates a new UTAMA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before UTAMA_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to UTAMA_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)". %
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help UTAMA
% Last Modified by GUIDE v2.5 20-Jun-2016 10:36:31
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @UTAMA_OpeningFcn, ...
'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1}); end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:}); end
% End initialization code - DO NOT EDIT
% --- Executes just before UTAMA is made visible.
function UTAMA_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn. % hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to UTAMA (see VARARGIN)
% Choose default command line output for UTAMA handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes UTAMA wait for user response (see UIRESUME)
% uiwait(handles.utama);
% --- Outputs from this function are returned to the command line.
function varargout = UTAMA_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in tombolEnkripsi. function tombolEnkripsi_Callback(hObject, eventdata, handles)
% hObject handle to tombolEnkripsi (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
respon = EMBEDDING('Title','embedding'); %enkripsi
% --- Executes on button press in tombolDekripsi. function tombolDekripsi_Callback(hObject, eventdata, handles)
% hObject handle to tombolDekripsi (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
respon = EXTRACTION('Title','extranction');
% --- Executes on button press in tombolKeluar. function tombolKeluar_Callback(hObject, eventdata, handles)
% hObject handle to tombolKeluar (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Lampiran 2. Embedding
function varargout = EMBEDDING(varargin) % embedding M-file for embedding.fig
% embedding, by itself, creates a new embedding or raises the existing
% singleton*. %
% H = embedding returns the handle to a new embedding or the handle to
% the existing singleton*.
% --- Executes on button press in proses.
function proses_Callback(hObject, eventdata, handles) % hObject handle to proses (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%INPUT GAMBAR
gambar = handles.Citra.RGB;
RGB = [gambar(:,:,2); gambar(:,:,1); gambar(:,:,3)];
%INPUT PESAN
pesan = handles.plainteks; panjangPesan = length (pesan); charPjgLSB = char(pjgLSB);
pesanLSB = [charPjgLSB, pesanLSB];
pesanLSB = uint8(pesanLSB);
[barisPesanLSB, kolomPesanLSB] = size(pesanLSB); counter = [1 1];
[baris, kolom, rgb] = size(RGB); besarGambar = baris*kolom;
banyakPesan = kolomPesanLSB*8; if banyakPesan > besarGambar
msgbox({'INPUT GAMBAR BERUKURAN LEBIH BESAR.'},'Message','modal');
else
for i=1:kolomPesanLSB
binerPesanLSB = dec2bin (pesanLSB(i),8);
r = 1;
lokasi = counter;
var(i) = RGB(counter(1), counter(2), r); counter(2) = counter(2) + 1;
if counter(2) > kolom counter(2) = 1;
counter(1) = counter(1)+1; end
lokasi(1,end+1) = counter(1); lokasi(1,end+1) = counter(2); end
var1 = dec2bin(var(1),8); var2 = dec2bin(var(2),8); var3 = dec2bin(var(3),8); var4 = dec2bin(var(4),8); var5 = dec2bin(var(5),8); var6 = dec2bin(var(6),8); var7 = dec2bin(var(7),8); var8 = dec2bin(var(8),8);
var1(8) = binerPesanLSB(1); var2(8) = binerPesanLSB(2);
var3(8) = binerPesanLSB(3); var4(8) = binerPesanLSB(4);
var5(8) = binerPesanLSB(5); var6(8) = binerPesanLSB(6);
var7(8) = binerPesanLSB(7); var8(8) = binerPesanLSB(8);
var1 = bin2dec(var1); var2 = bin2dec(var2); var3 = bin2dec(var3); var4 = bin2dec(var4); var5 = bin2dec(var5); var6 = bin2dec(var6); var7 = bin2dec(var7); var8 = bin2dec(var8);
RGB(lokasi(1),lokasi(2),r)=var1; RGB(lokasi(3),lokasi(4),r)=var2; RGB(lokasi(5),lokasi(6),r)=var3; RGB(lokasi(7),lokasi(8),r)=var4; RGB(lokasi(9),lokasi(10),r)=var5; RGB(lokasi(11),lokasi(12),r)=var6; RGB(lokasi(13),lokasi(14),r)=var7; RGB(lokasi(15),lokasi(16),r)=var8;
gambar= RGB; end
RGB;
ukuran = size(RGB); baris = ukuran(1); baris = baris/3; kolom = ukuran(2);
G = RGB(1:baris, 1:kolom);
gambarBaru = cat(3,R,G,B); end
%PESAN EOF pesanEOF = pesan(pjgLSB+1:panjangPesan); pesanEOF = double(pesanEOF);
penanda1 = double ('zx');
pesanEOF = [penanda1 pesanEOF 'zx']; [d e] = size(pesanEOF);
awal = gambarBaru; cover = gambarBaru; cover = double(cover); awal = double(awal);
[b k c] = size(cover); x = k;
status = 1;
status2 = false; while (~status2) x = x+1;
for i = 1:1:k
cover(i,x,1) = pesanEOF(status); status = status+1;
if(status>e)
status2 = true; break;
end
cover(i,x,2) = pesanEOF(status); status = status + 1;
if (status > e) status2 = true; break;
end
cover(i,x,3) = pesanEOF(status); status = status + 1;
if (status > e) status2 = true; break;
end end
if status2 == true break;
end end
Lampiran 3. Extraction
function varargout = EXTRACTION(varargin) % extraction M-file for extraction.fig
% extraction, by itself, creates a new extraction or raises the existing
% singleton*.
% --- Executes on button press in proses.
function proses_Callback(hObject, eventdata, handles) % hObject handle to proses (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
gambar = handles.Citra.RGB;
RGB = [gambar(:,:,2); gambar(:,:,1); gambar(:,:,3)];
[baris, kolom, rgb] = size(RGB); counter = [1 1];
r = 1;
lokasi = counter; for k=1:1
for i=1:8
var(i) = RGB(counter(1), counter(2), r); counter(2) = counter(2)+1;
if counter(2) > kolom counter(2) = 1;
counter(1) = counter(1)+1; end
lokasi(1,end+1)=counter(1); lokasi(1,end+1)=counter(2); end
var1 = dec2bin(var(1),8); var2 = dec2bin(var(2),8); var3 = dec2bin(var(3),8); var4 = dec2bin(var(4),8); var5 = dec2bin(var(5),8); var6 = dec2bin(var(6),8); var7 = dec2bin(var(7),8); var8 = dec2bin(var(8),8);
pesan(k,1)=var1(8); pesan(k,2)=var2(8); pesan(k,3)=var3(8); pesan(k,4)=var4(8); pesan(k,5)=var5(8); pesan(k,6)=var6(8); pesan(k,7)=var7(8); pesan(k,8)=var8(8); end
pesan= bin2dec(pesan);
pesan = native2unicode(pesan); panjangCipherteks = uint8(pesan);
for i=1:8
var(i) = RGB(counter(1), counter(2), r); counter(2) = counter(2)+1;
if counter(2) > kolom counter(2) = 1;
counter(1) = counter(1)+1; end
lokasi(1,end+1)=counter(1); lokasi(1,end+1)=counter(2); end
var1 = dec2bin(var(1),8); var2 = dec2bin(var(2),8); var3 = dec2bin(var(3),8); var4 = dec2bin(var(4),8); var5 = dec2bin(var(5),8); var6 = dec2bin(var(6),8); var7 = dec2bin(var(7),8); var8 = dec2bin(var(8),8); pesan(k,1)=var1(8); pesan(k,2)=var2(8);
pesan(k,3)=var3(8); pesan(k,4)=var4(8); pesan(k,5)=var5(8); pesan(k,6)=var6(8); pesan(k,7)=var7(8); pesan(k,8)=var8(8); end
pesan= bin2dec(pesan); pesan = char(pesan); cipherteks = pesan';
%EOF
cover = double(gambar); [b k c] = size(cover); penanda1 = ('zx');
penanda1 = double(penanda1); penanda1;
x = k;
kondisi = 0; for i = 1:1:k
tanda = [cover(1,i,1) cover(1,i,2)]; tanda = double(tanda);
if tanda == penanda1 kondisi = 1; indeks = i; break;
end end
if kondisi == 1
for l = 1:1:indeks-1 for t = 1:1:b
for rgb = 1:1:3
gambarku (t,l,rgb)=cover(t,l,rgb); end
end;
gambarku = uint8(gambarku);
sss=1; teks =[];
for i = indeks:1:k for j=1:1:b
teks = [teks char(cover(j,i,1))]; sss = sss+1;
teks = [teks char(cover(j,i,2))]; sss = sss+1;
teks = [teks char(cover(j,i,3))]; sss = sss+1;
end end
posisi = 3;
a = length(teks); for i=3:a-1
posisi1 = teks(i); posisi2 = teks(i+1); if (posisi1 == 'z') if(posisi2=='x') b=3;
b=i; end
end end;
baru=[]; for i=3:b
tekss = teks(i); baru = [baru tekss]; end
baru;
tampung=[];
for i=1:(length(baru)-1)
if baru(i) == 'z' && baru(i+1) =='x' break
end
tampung = [tampung baru(i)]; end
tampung; end
tampung;
handles.cipherteks = pesan; guidata(hObject, handles)