⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal2.m

📁 I try to create GUI using Matlab to code hills polygraph cipher
💻 M
📖 第 1 页 / 共 2 页
字号:



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


% --- Executes on selection change in pil1.
function pil1_Callback(hObject, eventdata, handles)
% hObject    handle to pil1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns pil1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from pil1



% --- Executes during object creation, after setting all properties.
function pil1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to pil1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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 plain_Callback(hObject, eventdata, handles)
% hObject    handle to plain (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 plain as text
%        str2double(get(hObject,'String')) returns contents of plain as a double
plain = get(hObject,'String');


% --- Executes during object creation, after setting all properties.
function plain_CreateFcn(hObject, eventdata, handles)
% hObject    handle to plain (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


% --- 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)
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 = encrypt(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 plihan.
function plihan_Callback(hObject, eventdata, handles)
% hObject    handle to plihan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close(hal2)
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 + -