des加密算法的JAVA实现窗口的实现部分
《des加密算法的JAVA实现窗口的实现部分》由会员分享,可在线阅读,更多相关《des加密算法的JAVA实现窗口的实现部分(8页珍藏版)》请在装配图网上搜索。
1、以下为DES加密算法的实现(附控制台输出调试代码)/* * Window.java * * Created on _DATE_, _TIME_ */package deswindow;import java.util.Scanner;/* * * author _USER_ */public class Window extends javax.swing.JFrame /* Creates new form Window */public Window() initComponents();/* This method is called from within the constructo
2、r to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */GEN-BEGIN:initComponents/ private void initComponents() button1 = new java.awt.Button();textField1 = new java.awt.TextField();textField2 = new java.awt.TextField()
3、;内容 = new java.awt.Label();密钥 = new java.awt.Label();textArea1 = new java.awt.TextArea();button2 = new java.awt.Button();setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);button1.setLabel(加密);button1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(
4、java.awt.event.ActionEvent evt) button1ActionPerformed(evt););textField1.setText(请输入明文或者密文);textField1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) textField1ActionPerformed(evt););textField2.setText(请输入密钥);textField2.addActionList
5、ener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) textField2ActionPerformed(evt););内容.setText(内容);密钥.setText(密钥);button2.setLabel(解密);button2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEven
6、t evt) button2ActionPerformed(evt););javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane();getContentPane().setLayout(layout);layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(127, 12
7、7, 127).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(textArea1,javax.swing.GroupLayout.Alignment.TRAILING,javax.swing.GroupLayout.DEFAULT_SIZE,124,Short.MAX_VALUE).addGroup(
8、layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup().addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(内容,javax.swing.GroupLayout
9、.PREFERRED_SIZE,38,javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(密钥,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addGap(2,2,2).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(tex
10、tField1,javax.swing.GroupLayout.DEFAULT_SIZE,84,Short.MAX_VALUE).addComponent(textField2,javax.swing.GroupLayout.DEFAULT_SIZE,84,Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(button1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.Group
11、Layout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(button2,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addGap(149, 149, 149);layout.setVerticalGroup(layout.createParallelGroup
12、(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(29, 29, 29).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(textField1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.Group
13、Layout.PREFERRED_SIZE).addComponent(内容,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
14、).addComponent(密钥,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(textField2,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swin
15、g.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(button2,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(button1,javax.swing.GroupLay
16、out.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(textArea1,javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZ
17、E).addContainerGap(91, Short.MAX_VALUE);pack();/ /GEN-END:initComponentsprivate void button2ActionPerformed(java.awt.event.ActionEvent evt) / 解密 得到两个输入框的输入值textArea1.setText();/textArea1.append(欢迎使用64位DES加密解密演示程序。+ );String data= textField1.getText();String key = textField2.getText();Des desUtil = n
18、ew Des(key);textArea1.append(解密前密文: + data+ );/ 加密后的byte型的密文byte result=data.getBytes();byte result1 = desUtil.DesEncrypt(result, 0);textArea1.append(解密后明文: + new String(result1);private void textField2ActionPerformed(java.awt.event.ActionEvent evt) private void textField1ActionPerformed(java.awt.ev
19、ent.ActionEvent evt) / TODO add your handling code here:private void button1ActionPerformed(java.awt.event.ActionEvent evt) textArea1.setText();/textArea1.append(欢迎使用64位DES加密解密演示程序。+ );String data = textField1.getText();String key = textField2.getText();Des desUtil = new Des(key);textArea1.append(加密
20、前明文: + data+ );/ 加密后的byte型的密文byte result = desUtil.DesEncrypt(data.getBytes(), 1);textArea1.append(加密后密文: + new String(result);/* * param args the command line arguments */public static void main(String args) java.awt.EventQueue.invokeLater(new Runnable() public void run() new Window().setVisible(tr
21、ue); );/GEN-BEGIN:variables/ Variables declaration - do not modifyprivate java.awt.Button button1;private java.awt.Button button2;private java.awt.TextArea textArea1;private java.awt.TextField textField1;private java.awt.TextField textField2;private java.awt.Label 内容;private java.awt.Label 密钥;/ End of variables declaration/GEN-END:variables
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。