Skip to content

Commit

Permalink
aes加密解密工具兼容java端,dp工具问题修复。
Browse files Browse the repository at this point in the history
aes加密解密工具兼容java端,dp工具问题修复。
  • Loading branch information
LiqiNew committed Jul 2, 2018
1 parent a4e42de commit be3285f
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 55 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-%E6%9D%8E%E5%A5%87-orange.svg)](https://github.com/LiqiNew)

# MyUtils
MyUtils是一个包含全方位的工具的工具项目。项目里面提供Base64编码解码工具、MD5加密工具、AES加密解码工具、SharePreference操作工具、
MyUtils是一个包含全方位的工具的工具项目。项目里面提供Base64编码解码工具、MD5加密工具、AES加密解码工具(支持android端平台加密解密,java端和android端相互加密解密)、SharePreference操作工具、
File文件操作工具、日期获取和计算工具、界面跳转Intent操作工具、字符串验证和数值转换操作工具、手机震动工具、系统资源操作工具、网络检测工具、
wifi操作工具、单位换算工具、zip压缩和解压操作工具、XML解析操作工具(只支持几种指定格式)、图片加载和处理工具,数据库操作(增删改查)工具。

Expand Down Expand Up @@ -32,7 +32,7 @@ allprojects {
```
**2:依赖MyUtils**<br>
```gradle
compile 'com.github.liqinew:myutils:V.1.1.1'
compile 'com.github.liqinew:myutils:V.1.1.2'
```

### [点击查阅MyUtils-API文档](https://liqinew.github.io/MyUtils/)
Expand All @@ -41,7 +41,8 @@ compile 'com.github.liqinew:myutils:V.1.1.1'

* **Base64**对象是Base64编码解码工具
* **MD5Util**对象是MD5加密工具
* **AESEncryptor**对象是AES加密解码工具
* **AndroidAESEncryptor**对象是Android端平台AES加密解密工具
* **JToAAesEncryptor**对象是java端和android端相互AES加密解密工具
* **BaseSharePreference**对象是SharePreference操作工具
* **StaticFileUtils**对象是File文件操作工具
* **TimeUtil**对象是日期获取和计算工具
Expand Down
25 changes: 25 additions & 0 deletions demo/src/main/java/com/liqi/myutils/demo/JavaTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.liqi.myutils.demo;

import com.liqi.utils.encoding.JToAAesEncryptor;

/**
* 模拟java端AES加密解密测试
* Created by LiQi on 2018/7/2.
*/

public class JavaTest {
public static final String KEY = "QQ:543945827----";

public static void main(String[] args) {
try {
String encryptContent = JToAAesEncryptor.encrypt(KEY, "加密内容");
System.out.print("加密出内容:" + encryptContent);


String decryptContent = JToAAesEncryptor.decrypt(KEY, encryptContent);
System.out.print("\n解密出内容:" + decryptContent);
} catch (Exception e) {
e.printStackTrace();
}
}
}
29 changes: 22 additions & 7 deletions demo/src/main/java/com/liqi/myutils/demo/TestOtherActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import com.liqi.utils.StaticUtility;
import com.liqi.utils.Validation;
import com.liqi.utils.VibratorUtil;
import com.liqi.utils.encoding.AESEncryptor;
import com.liqi.utils.encoding.AndroidAESEncryptor;
import com.liqi.utils.encoding.Base64;
import com.liqi.utils.encoding.JToAAesEncryptor;
import com.liqi.utils.encoding.MD5Util;
import com.liqi.utils.file.StaticFileUtils;
import com.liqi.utils.imageloader.ImageLoaderUtils;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void onClick(View v) {
}
});

//AES加密
//android端本地AES加密
findViewById(R.id.test_other_button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -84,16 +85,16 @@ public void onClick(View v) {
switch (mAseType) {
case 1:
try {
String encryptContent = AESEncryptor.encrypt("123456", content);
button.setText("AES要解密内容:" + encryptContent);
String encryptContent = AndroidAESEncryptor.encrypt128("123456", content);
button.setText("Android-本地AES要解密内容\n:" + encryptContent);
} catch (Exception e) {
e.printStackTrace();
}
break;
case 2:
try {
String decryptContent = AESEncryptor.decrypt("123456", content);
button.setText("AES要加密内容:" + decryptContent);
String decryptContent = AndroidAESEncryptor.decrypt128("123456", content);
button.setText("Android-本地AES要加密内容\n:" + decryptContent);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -102,7 +103,21 @@ public void onClick(View v) {
}
}
});

//解密Java端-AES加密内容
findViewById(R.id.test_other_button17).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button button = (Button) v;
//javaAES加密出来的密文,明文是:加密内容
String decryptContent = "3DF88A85EC0D0489269F09286D6C6B10";
try {
decryptContent = JToAAesEncryptor.decrypt(JavaTest.KEY, decryptContent);
} catch (Exception e) {
e.printStackTrace();
}
button.setText("解密Java端-AES加密内容\n" + decryptContent);
}
});
//Base64编码解码
findViewById(R.id.test_other_button3).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
8 changes: 6 additions & 2 deletions demo/src/main/res/layout/test_other_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
android:id="@+id/test_other_button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AES要加密内容:内容"/>

android:text="Android-本地AES要加密内容\n:Android-端AES-内容"/>
<Button
android:id="@+id/test_other_button17"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="解密Java端-AES加密内容"/>
<Button
android:id="@+id/test_other_button3"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Created by LiQi on 2017/12/6.
*/

enum DataBaseTypeEnum {
public enum DataBaseTypeEnum {
/**
* String类型
*/
Expand Down
Loading

0 comments on commit be3285f

Please sign in to comment.