带界面的aes算法java实现Word文档下载推荐.docx
《带界面的aes算法java实现Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《带界面的aes算法java实现Word文档下载推荐.docx(19页珍藏版)》请在冰豆网上搜索。
![带界面的aes算法java实现Word文档下载推荐.docx](https://file1.bdocx.com/fileroot1/2022-10/4/3626057c-e7ac-4b1f-8f32-01f576048b7f/3626057c-e7ac-4b1f-8f32-01f576048b7f1.gif)
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JRadioButton;
importjavax.swing.JTextField;
importjavax.swing.SwingConstants;
publicclassAESFrameextendsJFrameimplementsActionListener
{
privateJLabelsourceLabel,aimLabel,keyLabel;
privateJTextFieldsourceText,aimText,keyText;
privateJButtonencryptBt,decryptBt,clearBt,exitBt,
selectSourceBt,selectAimBt;
privateJRadioButton[]methodRadioButtons=newJRadioButton[2];
privateButtonGroupmethodGroup=newButtonGroup();
publicstaticvoidmain(String[]args)
{
newAESFrame("
AES加密解密工具By:
***"
);
}
publicAESFrame(Stringtitle)
super(title);
//初始化组件
keyLabel=newJLabel("
密钥"
SwingConstants.RIGHT);
sourceLabel=newJLabel("
源文件"
SwingConstants.RIGHT);
aimLabel=newJLabel("
目标文件"
keyText=newJTextField(20);
sourceText=newJTextField(20);
aimText=newJTextField(20);
encryptBt=newJButton("
加密"
decryptBt=newJButton("
解密"
clearBt=newJButton("
清空"
exitBt=newJButton("
退出"
selectSourceBt=newJButton("
浏览"
selectAimBt=newJButton("
methodRadioButtons[0]=newJRadioButton("
文件"
methodRadioButtons[1]=newJRadioButton("
字符串"
methodGroup.add(methodRadioButtons[0]);
methodGroup.add(methodRadioButtons[1]);
methodRadioButtons[0].setSelected(true);
//划分面板
Containerc=this.getContentPane();
c.setLayout(newBorderLayout());
JPanelcenterPanel=newJPanel();
JPanelnorthPanel=newJPanel();
JPanelsouthPanel=newJPanel();
JPaneleastPanel=newJPanel();
JPanelwestPanel=newJPanel();
c.add(eastPanel,BorderLayout.EAST);
c.add(westPanel,BorderLayout.WEST);
northPanel.setLayout(newGridLayout(1,3));
JPanelnorthLeftPanel=newJPanel();
JPanelnorthCenterPanel=newJPanel();
JPanelnorthRightPanel=newJPanel();
northCenterPanel.setLayout(newFlowLayout());
northCenterPanel.add(methodRadioButtons[0]);
northCenterPanel.add(methodRadioButtons[1]);
northPanel.add(northLeftPanel);
northPanel.add(northCenterPanel);
northPanel.add(northRightPanel);
c.add(northPanel,BorderLayout.NORTH);
southPanel.setLayout(newGridLayout(1,2));
JPanelsouthLeftPanel=newJPanel(newFlowLayout());
JPanelsouthRightPanel=newJPanel(newFlowLayout());
southLeftPanel.add(encryptBt);
southLeftPanel.add(decryptBt);
southRightPanel.add(clearBt);
southRightPanel.add(exitBt);
southPanel.add(southLeftPanel);
southPanel.add(southRightPanel);
c.add(southPanel,BorderLayout.SOUTH);
centerPanel.setLayout(newBorderLayout());
JPanelcenterEastPanel=newJPanel(newGridLayout(3,
1));
JPanelcenterWestPanel=newJPanel(newGridLayout(3,
JPanelcenterCenterPanel=newJPanel(newGridLayout(3,
JPanelcenterSouthPanel=newJPanel();
JPanelcenterNorthPanel=newJPanel();
JPanelpanel1=newJPanel(newFlowLayout());
JPanelpanel2=newJPanel(newFlowLayout());
JPanelpanel3=newJPanel(newFlowLayout());
JPanelpanel4=newJPanel(newFlowLayout());
JPanelpanel5=newJPanel(newFlowLayout());
JPanelpanel6=newJPanel(newFlowLayout());
JPanelpanel7=newJPanel(newFlowLayout());
JPanelpanel8=newJPanel(newFlowLayout());
JPanelpanel9=newJPanel(newFlowLayout());
panel1.add(sourceLabel);
panel2.add(sourceText);
panel3.add(selectSourceBt);
panel4.add(aimLabel);
panel5.add(aimText);
panel6.add(selectAimBt);
panel7.add(keyLabel);
panel8.add(keyText);
centerWestPanel.add(panel1);
centerWestPanel.add(panel4);
centerWestPanel.add(panel7);
centerCenterPanel.add(panel2);
centerCenterPanel.add(panel5);
centerCenterPanel.add(panel8);
centerEastPanel.add(panel3);
centerEastPanel.add(panel6);
centerEastPanel.add(panel9);
centerPanel.add(centerEastPanel,BorderLayout.EAST);
centerPanel.add(centerWestPanel,BorderLayout.WEST);
centerPanel.add(centerCenterPanel,BorderLayout.CENTER);
centerPanel.add(centerSouthPanel,BorderLayout.SOUTH);
centerPanel.add(centerNorthPanel,BorderLayout.NORTH);
c.add(centerPanel,BorderLayout.CENTER);
//加入按钮监听
encryptBt.addActionListener(this);
decryptBt.addActionListener(this);
clearBt.addActionListener(this);
exitBt.addActionListener(this);
selectSourceBt.addActionListener(this);
selectAimBt.addActionListener(this);
metho