欢迎访问成都祈钰瑶科技有限公司!

全国免费服务热线:

18982081108
✕

成都网站设计公司,成都响应式网站设计,成都移动端网站设计,成都网站UI设计

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

实现了基本的socket通信(即两台设备,一台用作服务器,一台用作客户端),服务器进行监听,客户端发送加密数据到服务器,服务器进行解密得到明文。

创新互联公司是一家专注于成都网站设计、网站制作、外贸营销网站建设与策划设计,围场网站建设哪家好?创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:围场等地区。围场做网站价格咨询:028-86922220

注意:本项目中使用了ButterKnife及EventBus作为辅助工具,通信建立时默认网络正常(未做局域网网络环境检测),加密方式为AES加密


1.效果图:

(1)客户端


(2)服务器端

2.界面布局部分

(1)服务器端布局 function_socket_server.xml

<?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 >

  <TextView
   
   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"
   android:layout_width="0dp"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:text="停止监听" />

  <Button
   android:id="@+id/btn_getUser"
   android:layout_width="0dp"
   android:layout_height="wrap_content"
   android:layout_weight="1"
   android:text="刷新用户" />
 </LinearLayout>


 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:padding="10dp">

  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="本机地址:" />

  <TextView
   android:id="@+id/tv_localAddress"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:singleLine="true" />
 </LinearLayout>


 <ScrollView
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical">


   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="接收到的明文:"
    android:textColor="@color/black" />

   <TextView
    android:id="@+id/tv_receivedContent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp" />

   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="解密后的明文:"
    android:textColor="@color/black" />

   <TextView
    android:id="@+id/tv_decryptContent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp" />
  </LinearLayout>

 </ScrollView>

</LinearLayout>