資源簡介
此網(wǎng)上聊天加密系統(tǒng)包含客戶端和服務(wù)端
有登錄、注冊的功能
聊天信息傳輸過程中會進行加密,然后再進行解密
主要的加密方法有:AES、 MD5、一起一些非對稱加密方法

代碼片段和文件信息
package?com.ChatServer;
//聊天室客戶端程序
import?javax.swing.*;
import?java.awt.*;
import?java.awt.event.*;
import?java.net.*;
import?java.io.*;
import?java.util.*;
public?class?ChatClient?extends?Jframe?implements?ActionListener?{
??JPanel?pnlLogin;
??JButton?btnLogin?btnRegisterbtnexit;
??JLabel?lblServer?lblPort?lblName?lblPassword?lblLogo;
??JTextField?tfName?tfServer?tfPort;
??JPasswordField?pwd;
??String?strServerIp;
??int?port;
??//用于將窗口定位
??Dimension?scnSize?=?Toolkit.getDefaultToolkit().getScreenSize();
??public?ChatClient()?{?//構(gòu)造方法
????super(“登錄簡單聊天系統(tǒng)“);
????pnlLogin?=?new?JPanel();
????this.getContentPane().add(pnlLogin);
????lblServer?=?new?JLabel(“服務(wù)器:“);
????lblPort?=?new?JLabel(“端口:“);
????lblPort.setVisible(false);
????lblName?=?new?JLabel(“用戶名:“);
????lblPassword?=?new?JLabel(“密?????碼:“);
????tfServer?=?new?JTextField(15);
????tfServer.setText(“127.16.220.178“);
????tfPort?=?new?JTextField(4);
????tfPort.setText(“8000“);
????tfPort.setVisible(false);
????tfName?=?new?JTextField(20);
????pwd?=?new?JPasswordField(20);
????btnLogin?=?new?JButton(“登錄“);
????btnRegister?=?new?JButton(“注冊“);
????btnexit=new?JButton(“取消“);
????pnlLogin.setLayout(null);?//組件用手動布局
????
????lblServer.setBounds(20?15?50?30);
????tfServer.setBounds(70?15?183?25);
????lblPort.setBounds(175?15?30?30);
????tfPort.setBounds(210?15?40?25);
????lblName.setBounds(20?50?50?30);
????tfName.setBounds(70?50?183?25);
????lblPassword.setBounds(20?80?50?30);
????pwd.setBounds(70?80?183?25);
????btnLogin.setBounds(50?120?60?25);
????btnexit.setBounds(120?120?60?25);
????btnRegister.setBounds(190?120?60?25);
????pnlLogin.add(lblServer);
????pnlLogin.add(tfServer);
????pnlLogin.add(lblPort);
????pnlLogin.add(tfPort);
????pnlLogin.add(lblName);
????pnlLogin.add(tfName);
????pnlLogin.add(lblPassword);
????pnlLogin.add(pwd);
????pnlLogin.add(btnLogin);
????pnlLogin.add(btnexit);
????pnlLogin.add(btnRegister);
???
????
????//設(shè)置登錄窗口
????setResizable(false);
????setSize(290?190);
????setVisible(true);
????setLocation((scnSize.width?-?getWidth())/2(scnSize.height?-?getHeight())/2);
????
????
????//為按鈕注冊監(jiān)聽
????btnexit.addActionListener(this);
????btnLogin.addActionListener(this);
????btnRegister.addActionListener(this);
???
???addWindowListener(new?WindowAdapter()?{
??????public?void?windowClosing(WindowEvent?e)?{
????????System.exit(0);
??????}
????});
?}
??//按鈕監(jiān)聽響應(yīng)
??public?void?actionPerformed(ActionEvent?ae)?{
????object?source?=?ae.getSource();
????strServerIp?=?tfServer.getText();
????try?{
??????port?=?Integer.valueOf(tfPort.getText());
??????if?(port?<=?1024)?{
????????JOptionPane.showMessageDialog(null?“請使用大于1024的端口號“);
????????return;
??????}
????}
????catch?(NumberFormatException?e)?{
??????JOptionPane.showMessageDialog(null?“輸入的端口號不是整數(shù)“);
????}
????if?(source.equals(btnLogin))?{??????
??????if?(tfName.getText().equals(““)?||?pwd.get
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4618??2011-11-06?21:25??Encrypted-?Server-System\ChatClient.java
?????文件???????5360??2011-12-12?18:27??Encrypted-?Server-System\ChatRoom.java
?????文件??????11180??2011-11-06?21:25??Encrypted-?Server-System\ChatServer.java
?????文件????????323??2008-01-12?14:11??Encrypted-?Server-System\key1.dat
?????文件???????1207??2011-06-30?21:22??Encrypted-?Server-System\MD5Util.class
?????文件????????737??2011-11-06?21:25??Encrypted-?Server-System\MD5Util.java
?????文件???????4374??2011-11-06?21:25??Encrypted-?Server-System\Register.java
?????文件????????323??2008-01-12?14:11??Encrypted-?Server-System\user.dat
?????文件????????624??2011-11-06?21:25??Encrypted-?Server-System\User.java
?????目錄??????????0??2011-12-18?20:05??Encrypted-?Server-System
-----------?---------??----------?-----??----
????????????????28746????????????????????10
評論
共有 條評論