网络安全基础课程设计.docx
- 文档编号:3928308
- 上传时间:2022-11-26
- 格式:DOCX
- 页数:21
- 大小:120.74KB
网络安全基础课程设计.docx
《网络安全基础课程设计.docx》由会员分享,可在线阅读,更多相关《网络安全基础课程设计.docx(21页珍藏版)》请在冰豆网上搜索。
网络安全基础课程设计
目录
1课程设计简介2
1.1课程设计的目的2
1.2课程设计内容2
2课程设计的整体实现过程2
2.1流程分析2
2.2算法实现代码4
2.3测试与评价18
3心得体会20
4参考文献21
1课程设计简介
1.1课程设计的目的
在数据加密解密算法中,RSA是典型的双密钥体制,目前均在大量使用。
通过实验,让我们充分理解和掌握RSA算法的使用。
这种加密算法的特点主要是密钥的变化,RSA同时有两把钥匙,公钥与私钥。
同时支持数字签名。
数字签名的意义在于,对传输过来的数据进行校验。
确保数据在传输工程中不被修改。
1.2课程设计内容
我们一组设计一个使用RSA算法进行加密解密的系统。
并设计操作界面,对输入的明文可以进行加解密以及对指定的文件可以加解密。
2课程设计的整体实现过程
2.1流程分析
甲方构建密钥对,将公钥公布给乙方,将私钥保留。
甲方使用私钥加密数据,然后用私钥对加密后的数据签名,发送给乙方签名以及加密后的数据;乙方使用公钥、签名来验证待解密数据是否有效,如果有效使用公钥对数据解密。
乙方使用公钥加密数据,向甲方发送经过加密后的数据;甲方获得加密数据,通过私钥解密。
2.2算法实现代码
packageRSA;
importjava.awt.*;
importjava.awt.event.*;
importjava.util.*;
//定义对话框类
classRsa_dialogextendsDialogimplementsActionListener
{
intmessage;
Panelpanel_dialog;
Buttonbutton_queding;
Labellabel_jinggao;
Rsa_dialog(Framef,Strings,booleanb,Stringjinggao)
{
super(f,s,b);
panel_dialog=newPanel();
panel_dialog.setLayout(null);
label_jinggao=newLabel(jinggao);
panel_dialog.add(label_jinggao);
label_jinggao.setBounds(2,2,145,40);
button_queding=newButton("确定");
panel_dialog.add(button_queding);
button_queding.setBounds(150/2-80/2,44,80,30);
button_queding.addActionListener(this);
add(panel_dialog);
Toolkittool=getToolkit();
Dimensiondim=tool.getScreenSize();
setBounds(dim.width/2-120/2,dim.height/2-150/2,150,120);
addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
message=-1;
setVisible(false);
}
}
);
}
publicvoidactionPerformed(ActionEvente)
{
if(e.getSource()==button_queding)
{
message=1;
setVisible(false);
}
}
}
classWindowAreaextendsFrameimplementsActionListener
{
//定义对话框
Rsa_dialogdialog_p,dialog_q,dialog_mingwen_n;
//定义——选择素数p、q
Stringstring_p,string_q;
longlong_p,long_q;
Panelpanel_p_q;
TextFieldtextfield_p,textfield_q;
Labellabel_p,label_q;
//定义——O(n)\nCA-IOS(799054470);
Stringstring_on,string_n;
longlong_on,long_n;
Panelpanel_on_n;
TextFieldtextfield_on,textfield_n;
Labellabel_on,label_n;
Buttonbutton_on,button_n;
//定义——可选择的整数e
Panelpanel_kexuan_e;
Labellabel_kexuan_e;
TextAreatextarea_kexuan_e;
Buttonbutton_e;
//定义——选择e
Panelpanel_xuanze_e;
Labellabel_xuanze_e;
TextFieldtextfield_xuanze_e;
//定义——d
Stringstring_e,string_d;
longlong_e,long_d;
Panelpanel_d;
Labellabel_d;
TextFieldtextfield_d;
Buttonbutton_d;
//定义——公钥
Panelpanel_gongyao;
Labellabel_gongyao_e,label_gongyao_n;
TextFieldtextfield_gongyao_e,textfield_gongyao_n;
Buttonbutton_gongyao;
//定义——私钥
Panelpanel_siyao;
Labellabel_siyao_d,label_siyao_n;
TextFieldtextfield_siyao_d,textfield_siyao_n;
Buttonbutton_siyao;
//定义——加密
longlong_jiami_mingwen,long_jiami_miwen;
Stringstring_jiami_mingwen,string_jiami_miwen;
Panelpanel_jiami;
TextFieldtextfield_jiami_mingwen,textfield_jiami_miwen;
Labellabel_jiami_mingwen,label_jiami_miwen;
Buttonbutton_jiami;
//定义——解密
longlong_jiemi_mingwen,long_jiemi_miwen;
Stringstring_jiemi_mingwen,string_jiemi_miwen;
Panelpanel_jiemi;
TextFieldtextfield_jiemi_mingwen,textfield_jiemi_miwen;
Labellabel_jiemi_mingwen,label_jiemi_miwen;
Buttonbutton_jiemi;
WindowArea(Strings)
{
super(s);
setLayout(null);
addWindowListener(newWindowAdapter()
{
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
}
);
//框架——选择素数p、q
panel_p_q=newPanel();
panel_p_q.setBounds(30,50,700,50);
panel_p_q.setLayout(null);
label_p=newLabel("选择素数p:
");
panel_p_q.add(label_p);
label_p.setBounds(10,10,150,20);
textfield_q=newTextField();
panel_p_q.add(textfield_q);
textfield_q.setBounds(160,10,75,20);
label_q=newLabel("选择素数q:
");
panel_p_q.add(label_q);
label_q.setBounds(245,10,150,20);
textfield_p=newTextField();
panel_p_q.add(textfield_p);
textfield_p.setBounds(405,10,75,20);
add(panel_p_q);
//框架——生成O(n)\n
panel_on_n=newPanel();
panel_on_n.setBounds(30,90,700,70);
panel_on_n.setLayout(null);
label_on=newLabel("O(n):
");
panel_on_n.add(label_on);
label_on.setBounds(10,10,100,20);
textfield_on=newTextField();
textfield_on.setEditable(false);
panel_on_n.add(textfield_on);
textfield_on.setBounds(160,10,75,20);
button_on=newButton("生成O(n)");
button_on.addActionListener(this);
panel_on_n.add(button_on);
button_on.setBounds(488,10,110,20);
label_n=newLabel("n:
");
panel_on_n.add(label_n);
label_n.setBounds(10,40,150,20);
textfield_n=newTextField();
textfield_n.setEditable(false);
panel_on_n.add(textfield_n);
textfield_n.setBounds(160,40,75,20);
button_n=newButton("生成n");
button_n.addActionListener(this);
panel_on_n.add(button_n);
button_n.setBounds(488,40,110,20);
add(panel_on_n);
//框架——可选择的e
panel_kexuan_e=newPanel();
panel_kexuan_e.setBounds(30,160,700,100);
panel_kexuan_e.setLayout(null);
label_kexuan_e=newLabel("可供选择的e有:
");
//label_kexuan_e.setBackground(Color.cyan);
panel_kexuan_e.add(label_kexuan_e);
label_kexuan_e.setBounds(10,10,150,20);
textarea_kexuan_e=newTextArea();
textarea_kexuan_e.setEditable(false);
panel_kexuan_e.add(textarea_kexuan_e);
textarea_kexuan_e.setBounds(160,10,250,80);
button_e=newButton("生成可供选择的e");
button_e.addActionListener(this);
panel_kexuan_e.add(button_e);
button_e.setBounds(488,10,110,20);
add(panel_kexuan_e);
//框架——选择e
panel_xuanze_e=newPanel();
panel_xuanze_e.setBounds(30,260,700,40);
//panel_xuanze_e.setBackground(Color.blue);
panel_xuanze_e.setLayout(null);
label_xuanze_e=newLabel("选择e为:
");
panel_xuanze_e.add(label_xuanze_e);
label_xuanze_e.setBounds(10,10,150,20);
textfield_xuanze_e=newTextField();
panel_xuanze_e.add(textfield_xuanze_e);
textfield_xuanze_e.setBounds(160,10,75,20);
add(panel_xuanze_e);
//框架——d
panel_d=newPanel();
panel_d.setBounds(30,310,700,40);
panel_d.setLayout(null);
label_d=newLabel("d为:
");
panel_d.add(label_d);
label_d.setBounds(10,10,150,20);
textfield_d=newTextField();
textfield_d.setEditable(false);
panel_d.add(textfield_d);
textfield_d.setBounds(160,10,75,20);
button_d=newButton("生成d");
button_d.addActionListener(this);
panel_d.add(button_d);
button_d.setBounds(488,10,110,20);
add(panel_d);
//框架——生成公钥KU
panel_gongyao=newPanel();
panel_gongyao.setBounds(30,360,700,40);
panel_gongyao.setLayout(null);
label_gongyao_e=newLabel("公钥KU为:
e");
panel_gongyao.add(label_gongyao_e);
label_gongyao_e.setBounds(10,10,150,20);
textfield_gongyao_e=newTextField();
textfield_gongyao_e.setEditable(false);
panel_gongyao.add(textfield_gongyao_e);
textfield_gongyao_e.setBounds(160,10,75,20);
label_gongyao_n=newLabel("n:
");
panel_gongyao.add(label_gongyao_n);
label_gongyao_n.setBounds(238,10,35,20);
textfield_gongyao_n=newTextField();
textfield_gongyao_n.setEditable(false);
panel_gongyao.add(textfield_gongyao_n);
textfield_gongyao_n.setBounds(280,10,95,20);
button_gongyao=newButton("生成公钥KU");
button_gongyao.addActionListener(this);
panel_gongyao.add(button_gongyao);
button_gongyao.setBounds(488,10,110,20);
add(panel_gongyao);
//框架——生成私钥KU
panel_siyao=newPanel();
panel_siyao.setBounds(30,410,700,40);
panel_siyao.setLayout(null);
label_siyao_d=newLabel("私钥KR为:
d");
panel_siyao.add(label_siyao_d);
label_siyao_d.setBounds(10,10,150,20);
textfield_siyao_d=newTextField();
textfield_siyao_d.setEditable(false);
panel_siyao.add(textfield_siyao_d);
textfield_siyao_d.setBounds(160,10,75,20);
label_siyao_n=newLabel("n:
");
panel_siyao.add(label_siyao_n);
label_siyao_n.setBounds(238,10,35,20);
textfield_siyao_n=newTextField();
textfield_siyao_n.setEditable(false);
panel_siyao.add(textfield_siyao_n);
textfield_siyao_n.setBounds(280,10,95,20);
button_siyao=newButton("生成私钥KR");
button_siyao.addActionListener(this);
panel_siyao.add(button_siyao);
button_siyao.setBounds(488,10,110,20);
add(panel_siyao);
//框架——加密
panel_jiami=newPanel();
panel_jiami.setBounds(30,460,700,70);
panel_jiami.setLayout(null);
label_jiami_mingwen=newLabel("输入明文:
");
panel_jiami.add(label_jiami_mingwen);
label_jiami_mingwen.setBounds(30,10,75,20);
textfield_jiami_mingwen=newTextField();
panel_jiami.add(textfield_jiami_mingwen);
textfield_jiami_mingwen.setBounds(160,10,215,20);
label_jiami_miwen=newLabel("输出密文:
");
panel_jiami.add(label_jiami_miwen);
label_jiami_miwen.setBounds(30,40,75,20);
textfield_jiami_miwen=newTextField();
textfield_jiami_miwen.setEditable(false);
panel_jiami.add(textfield_jiami_miwen);
textfield_jiami_miwen.setBounds(160,40,215,20);
button_jiami=newButton("加密");
button_jiami.addActionListener(this);
panel_jiami.add(button_jiami);
button_jiami.setBounds(488,10,110,20);
add(panel_jiami);
//框架——解密
panel_jiemi=newPanel();
panel_jiemi.setBounds(30,540,700,70);
panel_jiemi.setLayout(null);
label_jiemi_mingwen=newLabel("输出明文:
");
panel_jiemi.add(label_jiemi_mingwen);
label_jiemi_mingwen.setBounds(30,10,75,20);
textfield_jiemi_mingwen=newTextField();
textfield_jiemi_mingwen.setEditable(false);
panel_jiemi.add(textfield_jiemi_mingwen);
textfield_jiemi_mingwen.setBounds(160,10,215,20);
label_jiemi_miwen=newLabel("输入密文:
");
panel_jiemi.add(label_jiemi_miwen);
label_jiemi_miwen.setBounds(30,40,75,20);
textfield_jiemi_miwen=newTextField();
panel_jiemi.add(textfield_jiemi_miwen);
textfield_jiemi_miwen.setBounds(160,40,215,20);
button_jiemi=newButton("解密");
button_jiemi.addActionListener(this);
panel_jiemi.add(button_jiemi);
button_jiemi.setBounds(488,10,110,20);
add(panel_jiemi);
//总的外框架尺寸
Toolki
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 网络安全 基础 课程设计
![提示](https://static.bdocx.com/images/bang_tan.gif)