LAMPIRAN A
LISTINGPROGRAM
1. Form Utama (myProgram.fig)
function varargout = myProgram(varargin) gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @myProgram_OpeningFcn, ... 'gui_OutputFcn', @myProgram_OutputFcn, ... '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
function myProgram_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject; guidata(hObject, handles);
function varargout = myProgram_OutputFcn(hObject, eventdata, handles, varargin)
frontImage = imread('image1.jpg'); axes(handles.axes2);
imshow(frontImage);
varargout{1} = handles.output;
function help_btn_Callback(hObject, eventdata, handles, varargin) open Help.fig;
close(gcbf);
function run_btn_Callback(hObject, eventdata, handles) selection = questdlg(['WHAT WOULD YOU LIKE TO DO
?'],['MSA'],'ENCRYPT','DECRYPT','ENCRYPT'); if strcmp(selection,'ENCRYPT')
encrypt; close(gcbf);
elseif strcmp(selection,'DECRYPT') decrypt;
A2
function exit_btn_Callback(hObject, eventdata, handles) selection = questdlg(['EXIT APPLICATION
?'],['MSA'],'YES','NO','YES'); if strcmp(selection,'NO') return;
else
close(gcbf); end
function about_btn_Callback(hObject, eventdata, handles,varargin) open about.fig;
close(gcbf);
2. Form Proses Penyisipan (encrypt.fig)
function varargout = encrypt(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @encrypt_OpeningFcn, ... 'gui_OutputFcn', @encrypt_OutputFcn, ... '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
function encrypt_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject;
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line. function varargout = encrypt_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
function n_key_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
function m_key_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function m_key_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in encrypt_btn.
function encrypt_btn_Callback(hObject, eventdata, handles, varargin)
global myPublicKey
plaintext = get(handles.plaintext_edit,'String');
%convert into binary form
plaintext = dec2bin(plaintext,7)'; plaintext = plaintext(:)'-'0';
%set(handles.plaintext_edit,'String',num2str(plaintext));
[linePT plaintext_size] = size(plaintext); [linePK myPublicKey_size] = size(myPublicKey);
%count how many blocks according to the size of public key blockT = plaintext_size/myPublicKey_size;
if (blockT<1) blockT = 1; block = blockT;
myPublicKey_size = plaintext_size; else
block = blockT;
r = mod(plaintext_size,myPublicKey_size); if (r~=0)
block = block+1; end
end
global cipherDec %ciphertext in decimal form cipherDec=0;
j=1; hasil=0;
%result of multiplying binary digit of plaintext and key for k=1:1:block
for i=1:1:myPublicKey_size
global binModCipher binResultCipher reshapeRC reshapeBMC [line sizeCipherDec] = size(cipherDec);
for ind=1:1:sizeCipherDec
modCipher(ind) = mod(cipherDec(ind),128); %ciphertext 7 bit {SISA}
resultCipher(ind) = floor(cipherDec(ind)/128); end
binModCipher = dec2bin(modCipher,7);
reshapeBMC = reshape(binModCipher.',1,[]); binResultCipher = dec2bin(resultCipher,7);
reshapeRC = reshape(binResultCipher.',1,[]);
function plaintext_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function plaintext_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in open_btn.
function open_btn_Callback(hObject, eventdata, handles) global myPublicKey
global imageFile
[filename,pathname] = uigetfile({'*.txt','File Text (*.txt)'},'Browse File');
if isequal([filename,pathname],[0,0]) return;
else
myPublicKey = dlmread(fullfile(pathname,filename,'')); set(handles.publicKey_edit,'String',num2str(myPublicKey)); end
temp = myPublicKey;
[line sizePK] = size(temp); [b k c] = size(imageFile); sizeChar = floor(b*k*c/2);
maxChar1 = floor(sizeChar/7); bitChar = 7*maxChar1;
global maxNew if(sizePK>=7)
maxNew = maxChar1; elseif (sizePK<7)
maxTrue = floor(bitChar/sizePK); if(mod(bitChar,sizePK)~=0)
maxTrue = maxTrue+1; end
sisa = maxTrue-maxChar1; if(sisa>maxChar1)
maxNew = sisa - maxChar1; else
maxNew = maxChar1 - sisa; end
end
set(handles.char_max,'String',maxNew);
function publicKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function publicKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in browse_btn.
function browse_btn_Callback(hObject, eventdata, handles, varargin)
global imageFile
[fileName,pathName] = uigetfile({'*.bmp','Bitmap File (*.bmp)'},'Open File');
imageFile = imread(fullfile(pathName,fileName)); set(handles.fileName_ed,'String',fileName);
[b k c] = size(imageFile); bitdepth = c*8;
set(handles.BitFile,'String',bitdepth);
ImageSize = round((b*k*c)/1024);
set(handles.fileSIZE,'String',ImageSize);
function cipher_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function cipher_edit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in embd_btn.
function embd_btn_Callback(hObject, eventdata, handles, varargin) global imageFile
global reshapeBMC %hasil ciphertext global reshapeRC %sisa ciphertext %global binModCipher binResultCipher
[line1 sizeBMC] = size(reshapeBMC); %[line2 sizeResult] = size(reshapeRC); temp = double(imageFile);
%convert to binary
binTemp = dec2bin(temp); [b k] = size(binTemp);
%bagian I berisi bit SISA ciphertext for j=1:1:sizeBMC
binTemp(j,8) = reshapeBMC(j); %replace the last bit with sisa ciphertext
end split = floor(b/2);
%bagian II berisi bit HASIL BAGI ciphertext idx = 1;
for k=split+1:1:(split+sizeBMC) binTemp(k,8) = reshapeRC(idx); idx = idx+1;
end
steganoImage = bin2dec(binTemp); [row col dep] = size(imageFile);
%change into Image i = 1;
for x=1:1:dep %layer / bitdepth for y=1:1:col %colom
for z=1:1:row %row
StegImg(z,y,x) = steganoImage(i); i = i+1;
end end end
global SteganoImg
SteganoImg = double(StegImg); SteganoImg = uint8(SteganoImg);
warndlg('Embedding Proccess Success!','Information');
% --- Executes on button press in save_btn.
global fullname global SteganoImg
temp = SteganoImg;
[filename1, pathname] = uiputfile('SteganoImage.bmp','Save'); fullname = fullfile(pathname,filename1);
imwrite(temp,fullname);
% --- Executes on button press in view_btn.
function view_btn_Callback(hObject, eventdata, handles, varargin) view;
%close(gcbf);
% --- Executes on button press in new_btn.
function new_btn_Callback(hObject, eventdata, handles, varargin) set(handles.fileName_ed,'String','');
set(handles.BitFile,'String',''); set(handles.fileSIZE,'String','');
set(handles.publicKey_edit,'String',''); set(handles.plaintext_edit,'String',''); set(handles.cipher_edit,'String','');
% --- Executes on button press in exit_btn.
function exit_btn_Callback(hObject, eventdata, handles, varargin) selection = questdlg(['EXIT APPLICATION
?'],['MSA'],'YES','NO','YES'); if strcmp(selection,'NO') return;
else
myProgram; close(gcbf); end
function fileName_ed_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function fileName_ed_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function fileSize_ed_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function BitFile_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
function totalFrame_ed_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function fileSIZE_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes during object creation, after setting all properties.
function encrypt_btn_CreateFcn(hObject, eventdata, handles)
% --- Executes on button press in check.
function check_Callback(hObject, eventdata, handles, varargin) global maxNew
plaintext = get(handles.plaintext_edit,'String'); [line sizeP] = size(plaintext);
if(sizeP>maxNew)
msgbox(['Your Text Consists of ',num2str(sizeP),' Letters, GREATER THAN MaxChar'],'MSA','error');
else
msgbox('VALID: YOU CAN CONTINUE..','MSA','none'); set(handles.encrypt_btn,'enable','on');
set(handles.embd_btn,'enable','on'); set(handles.save_btn,'enable','on'); set(handles.view_btn,'enable','on'); end
3. Form Proses Ekstraksi (decrypt.fig)
function varargout = decrypt(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @decrypt_OpeningFcn, ... 'gui_OutputFcn', @decrypt_OutputFcn, ... '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 decrypt is made visible.
function decrypt_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for decrypt handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% --- Outputs from this function are returned to the command line. function varargout = decrypt_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
% --- Executes on button press in steg_image_btn.
function steg_image_btn_Callback(hObject, eventdata, handles, varargin)
global imageSteganoFile
[fileName,pathName] = uigetfile({'*.bmp','Bitmap File (*.bmp)'},'Open File');
imageSteganoFile = imread(fullfile(pathName,fileName)); set(handles.fileName_edit,'String',fileName);
set(handles.width_edit,'String',size(imageSteganoFile,1)); set(handles.height_edit,'String',size(imageSteganoFile,2));
% --- Executes on button press in check_btn.
function check_btn_Callback(hObject, eventdata, handles)
function plaintext_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function plaintext_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in extract__btn.
function extract__btn_Callback(hObject, eventdata, handles, varargin)
global imageSteganoFile
tempImage = double(imageSteganoFile);
%convert to binary
A9
binImageFile = dec2bin(tempImage); [b k c] = size(imageSteganoFile);
split = floor(b*k*c/2); piksel = floor(split/7); piksel = piksel*7; d = mod(split,7);
if(d~=0)
%bagian I SISA cipher for i=1:1:piksel
lastBit1(i) = binImageFile(i,8); end
in=1;
ind2 = split+1;
%bagian II HASIL cipher
for j=ind2:1:(ind2+piksel-1) lastBit2(in) = binImageFile(j,8); in=in+1;
end
elseif(d==0)
%bagian I SISA cipher for i=1:1:split
lastBit1(i) = binImageFile(i,8); end
in=1;
%bagian II HASIL cipher for j=split+1:1:((b*k*c))
lastBit2(in) = binImageFile(j,8); in=in+1;
end end
binValues = [64 32 16 8 4 2 1];
binMatriksMod = reshape(lastBit1,7,[]).'; [br kl] = size(binMatriksMod);
binMatriksRest = reshape(lastBit2,7,[]).';
tempMod = 0; tempRes = 0;
[line sizeAll] = size(hasilRes);
for idx=1:1:sizeAll
ciphers(idx) = 128*hasilRes(idx)+hasilMod(idx); end
set(handles.cipher_edit,'String',num2str(ciphers));
function cipher_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function cipher_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in privateKey_btn.
function privateKey_btn_Callback(hObject, eventdata, handles) global mySecretKey
[filename,pathname] = uigetfile({'*.txt','File Text (*.txt)'},'Browse File');
if isequal([filename,pathname],[0,0]) return;
else
mySecretKey = dlmread(fullfile(pathname,filename,'')); set(handles.nKey_edit,'String',num2str(mySecretKey(1))); set(handles.mKey_edit,'String',num2str(mySecretKey(2))); end
function mKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function mKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function nKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function nKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function privKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function privKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in reset_btn.
function reset_btn_Callback(hObject, eventdata, handles, varargin) set(handles.fileName_edit,'String','');
set(handles.width_edit,'String',''); set(handles.height_edit,'String',''); set(handles.nKey_edit,'String',''); set(handles.mKey_edit,'String',''); set(handles.privKey_edit,'String',''); set(handles.cipher_edit,'String','');
set(handles.plaintextKey_edit,'String','');
% --- Executes on button press in exit_btn.
function exit_btn_Callback(hObject, eventdata, handles) selection = questdlg(['BACK TO MAIN MENU
?'],['MSA'],'YES','NO','YES'); if strcmp(selection,'NO') return;
else
myProgram; close(gcbf); end
% --- Executes on button press in generate_btn.
function generate_btn_Callback(hObject, eventdata, handles) selection = questdlg(['EXIT DECRYPT FORM
?'],['MSA'],'YES','NO','YES'); if strcmp(selection,'NO') return;
else
generate; close(gcbf); end
% --- Executes on button press in save_btn.
function save_btn_Callback(hObject, eventdata, handles, varargin) teks = get(handles.plaintext_edit,'String');
thedir='C:\Users\User\Desktop';
dlmwrite(fullfile(thedir, 'myPlaintext.txt'), teks, '');
warndlg('Plaintext has been saved as [myPlaintext.txt] into your desktop!','Information');
% --- Executes on button press in view_btn.
function view_btn_Callback(hObject, eventdata, handles)
function width_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function width_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function height_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function height_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function fileName_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function fileName_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in viewPK_btn.
function viewPK_btn_Callback(hObject, eventdata, handles) global myPrivateKey;
global myPrivateKey_size; global mySecretKey;
global mySecretKey_size;
myPrivateKey = 0; j = 3;
[linePK mySecretKey_size] = size(mySecretKey); myPrivateKey_size = mySecretKey_size - 2;
for i=1:1:myPrivateKey_size
myPrivateKey(i) = mySecretKey(j); j = j + 1;
end
set(handles.privKey_edit,'String',num2str(myPrivateKey));
% --- Executes on button press in dec_btn.
function dec_btn_Callback(hObject, eventdata, handles) %count the invers on nKey
inverseTemp = str2num(get(handles.nKey_edit,'String')); mTemp = str2num(get(handles.mKey_edit,'String'));
k = 0;
while k>=0
inverseN = (1 + (double(k)*mTemp))/double(inverseTemp); if (round(inverseN)-inverseN==0 && inverseN>0)
break; end
k = k + 1; end
%decryption process
ciphertext = str2num(get(handles.cipher_edit,'String')); [linePK ciphertext_size] = size(ciphertext);
for i=1:1:ciphertext_size
cipherTransform(i) = mod((inverseN*ciphertext(i)),mTemp); end
global myPrivateKey
global myPrivateKey_size;
%solving the super increasing knapsack x=myPrivateKey_size;
ind = 1;
for y = 1:ciphertext_size
for z = myPrivateKey_size:-1:1
if cipherTransform(y) >= myPrivateKey(z) plaintextBin(ind,x) = 1;
cipherTransform(y) = cipherTransform(y) - myPrivateKey(z);
else
plaintextBin(ind,x) = 0; end
x = x-1;
if(y>ciphertext_size) break;
end
end
x = myPrivateKey_size; ind = ind+1;
if cipherTransform(y) ~= 0
warning = 'Cannot Decrypt, because its not a superIncreasing Knapsack';
set(handles.plaintext_edit,'String',warning); break;
end end
a = reshape(plaintextBin.',1,[]); [line sizeA] = size(a);
j=mod(sizeA,7); for i = 1:1:sizeA-j b(i) = a(i); end
k = bin2dec((reshape(char(b+'0'),7,[])')); k = char(k);
k = reshape(k.',1,[]);
set(handles.plaintext_edit,'String',k);
% --- Executes on button press in pubKeyText.
function pubKeyText_Callback(hObject, eventdata, handles)
4. Form Proses Pembangkit Kunci (generate.fig)
function varargout = generate(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @generate_OpeningFcn, ... 'gui_OutputFcn', @generate_OutputFcn, ... '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 generateKey is made visible. function generate_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% --- Outputs from this function are returned to the command line. function varargout = generate_OutputFcn(hObject, eventdata,
handles)
% Get default command line output from handles structure varargout{1} = handles.output;
function mKey_edit_Callback(hObject, eventdata, handles)
function mKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function nKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function nKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in val_btn.
function val_btn_Callback(hObject, eventdata, handles,varargin) global total_result
mKey1 = str2num(get(handles.mKey_edit,'String')); nKey1 = str2num(get(handles.nKey_edit,'String'));
mKey = mKey1; nKey = nKey1;
while nKey~=0
sisa=mod(mKey,nKey); mKey=nKey;
nKey=sisa; end
result = mKey;
%choice
if (mKey1 > nKey1) && (result == 1) && (mKey1 > total_result)
msgbox('VALID: YOU CAN CONTINUE..','MSA','none'); set(handles.reset_btn,'enable','on');
set(handles.save_btn,'enable','on'); set(handles.pubKey_btn,'enable','on'); else
msgbox(['NOT VALID: CHECK M > ',num2str(total_result),', M > N, M-N COPRIME..'],'MSA','error');
end
function pk1_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function pk1_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
function pk2_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function pk2_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on selection change in inc.
function inc_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function inc_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in generate_btn. function generate_btn_Callback(hObject, eventdata, handles,varargin)
global total_result; total_result = 0;
pk1 = str2num(get(handles.pk1_edit,'String')); pk2 = str2num(get(handles.pk2_edit,'String')); increament = get(handles.inc,'Value');
totalPK = str2num(get(handles.total,'String'));
if totalPK < 3
msgbox('Total private key must be greater than 3 elements','MSA','error');
else
A(1) = pk1; A(2) = pk2;
temp = 0;
for i = 3:1:totalPK for j = 1:1:i-1
temp = temp + A(j); end
A(i) = temp + increament; temp = 0;
end
total_result = (A(totalPK)*2-increament);
set(handles.privateKey_edit,'String',num2str(A)); set(handles.val_btn,'enable','on');
set(handles.mKey_edit,'enable','on'); set(handles.nKey_edit,'enable','on');
end
function privateKey_edit_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function privateKey_edit_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in save_btn.
function save_btn_Callback(hObject, eventdata, handles, varargin) PK = str2num(get(handles.privateKey_edit,'String'));
nKey = str2num(get(handles.nKey_edit,'String')); mKey = str2num(get(handles.mKey_edit,'String'));
A(1) = nKey; A(2) = mKey;
Key = [A,PK];
thedir=uigetdir();%'C:\Users\User\Desktop';
dlmwrite(fullfile(thedir, 'mySecretKey.txt'), Key, ' '); warndlg('PrivateKey has been saved as
[mySecretKey.txt]','Information');
% --- Executes on button press in exit_btn.
function exit_btn_Callback(hObject, eventdata, handles)
selection = questdlg(['BACK TO MAIN MENU ?'],['MSA'],'YES','NO','YES');
if strcmp(selection,'NO') return;
else
myProgram; close(gcbf); end
% --- Executes on button press in reset_btn.
function reset_btn_Callback(hObject, eventdata, handles, varargin) set(handles.privateKey_edit,'String','');
set(handles.nKey_edit,'String',''); set(handles.mKey_edit,'String',''); set(handles.pk1_edit,'String',''); set(handles.pk2_edit,'String',''); set(handles.total,'String','');
% --- Executes during object creation, after setting all properties.
function val_btn_CreateFcn(hObject, eventdata, handles, varargin)
% --- Executes on button press in pubKey_btn.
function pubKey_btn_Callback(hObject, eventdata, handles, varargin)
PK = str2num(get(handles.privateKey_edit,'String')); nKey = str2num(get(handles.nKey_edit,'String')); mKey = str2num(get(handles.mKey_edit,'String'));
[line sizePK] = size(PK);
for i = 1:1:sizePK
pubKey(i) = mod((PK(i)*nKey),mKey); end
thedir=uigetdir();%'C:\Users\User\Desktop';
dlmwrite(fullfile(thedir, 'myPublicKey.txt'), pubKey, ' '); warndlg('PublicKey has been created as
[myPublicKey.txt]!','Information');
function total_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function total_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
% --- Executes during object creation, after setting all properties.
function generate_btn_CreateFcn(hObject, eventdata, handles)
5. FormView Image (view.fig)
function varargout = view(varargin)
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @view_OpeningFcn, ... 'gui_OutputFcn', @view_OutputFcn, ... '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 view is made visible.
function view_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject;
% Update handles structure guidata(hObject, handles);
function varargout = view_OutputFcn(hObject, eventdata, handles, varargin)
global imageFile fullname axes(handles.before); imshow(imageFile); axes(handles.after); imshow(fullname);
varargout{1} = handles.output;
% --- Executes on button press in BACK.
function BACK_Callback(hObject, eventdata, handles, varargin) %encrypt;
close(gcbf);
% --- Executes during object creation, after setting all properties.
function asli_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
function hasil_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function hasil_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
6. FormHelp (help.fig)
function varargout = help(varargin)
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @help_OpeningFcn, ... 'gui_OutputFcn', @help_OutputFcn, ... '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 Help is made visible.
function help_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% --- Outputs from this function are returned to the command line. function varargout = help_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles) myProgram;
close(gcbf);
7. FormAbout (about.fig)
function varargout = about(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @about_OpeningFcn, ... 'gui_OutputFcn', @about_OutputFcn, ... '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
function about_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject;
guidata(hObject, handles);
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles, varargin)
CURRICULUM VITAE
Nama
: Juwita Adelina Pasaribu
Alamat Sekarang
: Jl. Tuba II Gg. Tapanuli No. 11b Medan
Alamat Orang Tua : Jl. Tuba II Gg. Tapanuli No. 11b Medan
Telp/HP
: 0856 619 2245
: [email protected]
Riwayat Pendidikan
SDN 068084 Medan dari Tahun 1996 s/d Tahun 2002
SMPN 3 Medan dari Tahun 2002 s/d Tahun 2005
SMAN5 Medan dari Tahun 2005 s/d Tahun 2008
Universitas Sumatera Utara dari Tahun 2008 s/d Tahun 2012
Keahlian/Kursus yang diikuti
1. English Course at International Language Program
2. Office Application: Word, Excel, Powerpoint, Access