📄 hal3.asv
字号:
function varargout = hal3(varargin)
% HAL3 M-file for hal3.fig
% HAL3, by itself, creates a new HAL3 or raises the existing
% singleton*.
%
% H = HAL3 returns the handle to a new HAL3 or the handle to
% the existing singleton*.
%
% HAL3('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HAL3.M with the given input arguments.
%
% HAL3('Property','Value',...) creates a new HAL3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before hal3_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to hal3_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help hal3
% Last Modified by GUIDE v2.5 29-Jan-2007 03:05:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @hal3_OpeningFcn, ...
'gui_OutputFcn', @hal3_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 hal3 is made visible.
function hal3_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 hal3 (see VARARGIN)
% Choose default command line output for hal3
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes hal3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = hal3_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
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function a_Callback(hObject, eventdata, handles)
% hObject handle to a (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 a as text
% str2double(get(hObject,'String')) returns contents of a as a double
a = str2double(get(hObject, 'String'));
if isnan(a)
set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function a_CreateFcn(hObject, eventdata, handles)
% hObject handle to a (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function b_Callback(hObject, eventdata, handles)
% hObject handle to b (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 b as text
% str2double(get(hObject,'String')) returns contents of b as a double
b = str2double(get(hObject, 'String'));
if isnan(b)
set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function b_CreateFcn(hObject, eventdata, handles)
% hObject handle to b (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function c_Callback(hObject, eventdata, handles)
% hObject handle to c (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 c as text
% str2double(get(hObject,'String')) returns contents of c as a double
c = str2double(get(hObject, 'String'));
if isnan(c)
set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function c_CreateFcn(hObject, eventdata, handles)
% hObject handle to c (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function d_Callback(hObject, eventdata, handles)
% hObject handle to d (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 d as text
% str2double(get(hObject,'String')) returns contents of d as a double
d = str2double(get(hObject, 'String'));
if isnan(d)
% set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function d_CreateFcn(hObject, eventdata, handles)
% hObject handle to d (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function k1_Callback(hObject, eventdata, handles)
% hObject handle to k1 (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 k1 as text
% str2double(get(hObject,'String')) returns contents of k1 as a double
k1 = str2double(get(hObject, 'String'));
if isnan(k1)
set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function k1_CreateFcn(hObject, eventdata, handles)
% hObject handle to k1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function k2_Callback(hObject, eventdata, handles)
% hObject handle to k2 (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 k2 as text
% str2double(get(hObject,'String')) returns contents of k2 as a double
k2 = str2double(get(hObject, 'String'));
if isnan(k2)
set(hObject, 'String', 0);
errordlg('Input harus bilangan','Error');
end
% --- Executes during object creation, after setting all properties.
function k2_CreateFcn(hObject, eventdata, handles)
% hObject handle to k2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function kk_Callback(hObject, eventdata, handles)
% hObject handle to kk (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 kk as text
% str2double(get(hObject,'String')) returns contents of kk as a double
kk = get(hObject,'String');
% --- Executes during object creation, after setting all properties.
function kk_CreateFcn(hObject, eventdata, handles)
% hObject handle to kk (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function rk1_Callback(hObject, eventdata, handles)
% hObject handle to rk1 (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 rk1 as text
% str2double(get(hObject,'String')) returns contents of rk1 as a double
% --- Executes during object creation, after setting all properties.
function rk1_CreateFcn(hObject, eventdata, handles)
% hObject handle to rk1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function cipher_Callback(hObject, eventdata, handles)
% hObject handle to cipher (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 cipher as text
% str2double(get(hObject,'String')) returns contents of cipher as a double
% --- Executes during object creation, after setting all properties.
function cipher_CreateFcn(hObject, eventdata, handles)
% hObject handle to cipher (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function plain_Callback(hObject, eventdata, handles)
% hObject handle to cipher (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 cipher as text
% str2double(get(hObject,'String')) returns contents of cipher as a double
plain = get(hObject,'String');
% --- Executes during object creation, after setting all properties.
function plain_CreateFcn(hObject, eventdata, handles)
% hObject handle to cipher (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in decrypt.
function decrypt_Callback(hObject, eventdata, handles)
% hObject handle to decrypt (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = str2double(get(handles.a,'String'));
b = str2double(get(handles.b,'String'));
c = str2double(get(handles.c,'String'));
d = str2double(get(handles.d,'String'));
k1= str2double(get(handles.k1,'String'));
k2= str2double(get(handles.k2,'String'));
plain = get(handles.plain,'String');
kk = get(handles.kk,'String');
tes1 = get(handles.ks,'Value');
tes2 = get(handles.sctr,'Value');
tes3 = get(handles.kctr,'Value');
if tes1 == 1
rk = x(kk);
%set(handles.reskey,'string',rk1);
elseif tes2 == 1
rk = sctrx(kk);
%set(handles.reskey,'string',rk1);
elseif tes3 == 1
rk = kctrx(kk);
%set(handles.reskey,'string',rk1);
end
fprintf('%d\n',k1);
if tes1 == 0 & tes2 == 0 & tes3 == 0
errordlg('Anda belum memilih sistem','Error');
end
set(handles.rk1,'string',rk);
fprintf('%c\n',rk(1));
sandi = decrypt(plain,rk,a,b,c,d,k1,k2);
%cipher = int2str(cipher);
%l = size(sandi);
%sandi = grup(sandi,l);
sandi = buax(sandi);
set(handles.rk1,'string',rk);
set(handles.cipher,'String', sandi);
% --- Executes on button press in pilihan.
function pilihan_Callback(hObject, eventdata, handles)
% hObject handle to pilihan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(hal3)
button = questdlg('Mau Lagi ?',...
'Pilih','Yes','No','No');
switch button
case 'Yes',
hal1
case 'No',
msgbox('Thank You',...
'Sayonara');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -