android基于socket的局域网内服务器与客户端加密通信


android基于socket的局域网内服务器与客户端加密通信


实现了基本的socket通信(即两台设备 , 一台用作服务器 , 一台用作客户端) , 服务器进行监听 , 客户端发送加密数据到服务器 , 服务器进行解密得到明文 。
注意:本项目中使用了ButterKnife及EventBus作为辅助工具 , 通信建立时默认网络正常(未做局域网网络环境检测) , 加密方式为AES加密
1.效果图:
(1)客户端
android基于socket的局域网内服务器与客户端加密通信



(2)服务器端
android基于socket的局域网内服务器与客户端加密通信



2.界面布局部分
(1)服务器端布局 function_socket_server.xml
?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout style="@style/ToolBar">
<TextView
style="@style/ToolBar_tv_Title"
android:text="网络加密-服务器端" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn_startListener"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="启动监听" />
<Button
android:id="@+id/btn_stopListener"

推荐阅读