├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ ├── arm64-v8a
│ │ ├── libbase.so
│ │ ├── libc++.so
│ │ ├── libcademo.so
│ │ ├── libcademostvels.so
│ │ ├── libcutils.so
│ │ └── libtrusty.so
│ ├── armeabi-v7a
│ │ ├── libbase.so
│ │ ├── libc++.so
│ │ ├── libcademo.so
│ │ ├── libcademostvels.so
│ │ ├── libcutils.so
│ │ └── libtrusty.so
│ └── armeabi
│ │ ├── libbase.so
│ │ ├── libc++.so
│ │ ├── libcademo.so
│ │ ├── libcademostvels.so
│ │ ├── libcutils.so
│ │ └── libtrusty.so
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── revo
│ │ └── aesrsa
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── revo
│ │ │ └── aesrsa
│ │ │ ├── JniUtil.class
│ │ │ ├── JniUtil.java
│ │ │ ├── MainActivity.java
│ │ │ └── resrsa
│ │ │ ├── AES.java
│ │ │ ├── AesUtils.java
│ │ │ ├── Base64.java
│ │ │ ├── CheckUtils.java
│ │ │ ├── ConfigureEncryptAndDecrypt.java
│ │ │ ├── ConvertUtils.java
│ │ │ ├── Digest.java
│ │ │ ├── EncryUtil.java
│ │ │ ├── EncryptionUtil.java
│ │ │ ├── RSA.java
│ │ │ └── SecureRandomUtil.java
│ ├── jni
│ │ ├── Android.mk
│ │ ├── Application.mk
│ │ ├── JniLib.cpp
│ │ ├── JniUtil.c
│ │ ├── aes256.c
│ │ ├── aes256.h
│ │ ├── base64.c
│ │ ├── base64.h
│ │ ├── com_revo_aesrsa_JniUtil.h
│ │ └── tipc.h
│ ├── libs
│ │ ├── arm64-v8a
│ │ │ └── libJniUtil.so
│ │ ├── armeabi-v7a
│ │ │ └── libJniUtil.so
│ │ ├── armeabi
│ │ │ └── libJniUtil.so
│ │ ├── mips
│ │ │ └── libJniUtil.so
│ │ ├── mips64
│ │ │ └── libJniUtil.so
│ │ ├── x86
│ │ │ └── libJniUtil.so
│ │ └── x86_64
│ │ │ └── libJniUtil.so
│ ├── obj
│ │ └── local
│ │ │ ├── arm64-v8a
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── aes_cbc.o
│ │ │ │ ├── aes_cbc.o.d
│ │ │ │ ├── aes_core.o
│ │ │ │ ├── aes_core.o.d
│ │ │ │ ├── aes_ecb.o
│ │ │ │ ├── aes_ecb.o.d
│ │ │ │ ├── base64.o
│ │ │ │ ├── base64.o.d
│ │ │ │ ├── cbc128.o
│ │ │ │ └── cbc128.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ ├── armeabi-v7a
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ ├── armeabi
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ ├── mips
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ ├── mips64
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ ├── x86
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ │ ├── JniLib
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ │ └── JniUtil
│ │ │ │ ├── JniLib.o
│ │ │ │ ├── JniLib.o.d
│ │ │ │ ├── JniUtil.o
│ │ │ │ ├── JniUtil.o.d
│ │ │ │ ├── aes256.o
│ │ │ │ ├── aes256.o.d
│ │ │ │ ├── base64.o
│ │ │ │ └── base64.o.d
│ │ │ └── x86_64
│ │ │ ├── libJniLib.so
│ │ │ ├── libJniUtil.so
│ │ │ ├── libstdc++.a
│ │ │ └── objs
│ │ │ ├── JniLib
│ │ │ ├── JniLib.o
│ │ │ ├── JniLib.o.d
│ │ │ ├── JniUtil.o
│ │ │ ├── JniUtil.o.d
│ │ │ ├── aes256.o
│ │ │ ├── aes256.o.d
│ │ │ ├── base64.o
│ │ │ └── base64.o.d
│ │ │ └── JniUtil
│ │ │ ├── JniLib.o
│ │ │ ├── JniLib.o.d
│ │ │ ├── JniUtil.o
│ │ │ ├── JniUtil.o.d
│ │ │ ├── aes256.o
│ │ │ ├── aes256.o.d
│ │ │ ├── base64.o
│ │ │ └── base64.o.d
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── revo
│ └── aesrsa
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # androidRsaAES
2 |
3 | android对数据加密传输 ,android JNI C++ 实现 AES 加密 解密 数据 以及 java RSA 对AES秘钥进行解密传输
4 |
5 | C++ 和 Java 实现 AES 加密 解密 ,二种都能相互直接加密和解密
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "30.0.1"
6 | defaultConfig {
7 | applicationId "com.revo.fuckdemo"
8 | minSdkVersion 21
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | ndk{
14 | moduleName "JniUtil"
15 | ldLibs "log"//实现__android_log_print
16 | abiFilters "armeabi","armeabi-v7a","arm64-v8a" //输出指定的三种abi体系下的so库"armeabi",只加载armabi架构(目录下)的so库,如果是别的架构,就会找不到
17 |
18 | }
19 | sourceSets{ //不配的话都会有一个默认值 可以指定哪些源文件(或文件夹下的源文件)要被编译,哪些源文件要被排除
20 | main{
21 | jni.srcDirs = [] //禁用as自动生成mk
22 | //jniLibs.srcDirs=["src/main/libs" ] //so包就去src/main/libs目录下找
23 | //jniLibs.srcDirs=['libs']
24 | }
25 | }
26 | }
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 | task ndkBuild(type:Exec,description:'Compile JNI source via NDK'){
34 | commandLine "D:\\SDK\\sdk\\ndk\\android-ndk-r14b\\ndk-build.cmd",//配置ndk的路径
35 | 'NDK_PROJECT_PATH=build/intermediates/ndk',//ndk默认的生成so的文件
36 | 'NDK_LIBS_OUT=src/main/libs',//配置的我们想要生成的so文件所在的位置
37 | 'APP_BUILD_SCRIPT=src/main/jni/Android.mk',//指定项目以这个mk的方式
38 | 'NDK_APPLOCATION_MK=src/main/jni/Application.mk'//指定项目以这个mk的方式
39 | }
40 | externalNativeBuild {
41 | ndkBuild {
42 | path file('src/main/jni/Android.mk')
43 | }
44 | }
45 | }
46 |
47 | dependencies {
48 | implementation fileTree(dir: 'libs', include: ['*.jar'])
49 | implementation 'androidx.appcompat:appcompat:1.1.0'
50 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
51 | testImplementation 'junit:junit:4.12'
52 | androidTestImplementation 'androidx.test:runner:1.2.0'
53 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
54 | }
55 |
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libbase.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libbase.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libc++.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libc++.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libcademo.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libcademo.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libcademostvels.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libcademostvels.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libcutils.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libcutils.so
--------------------------------------------------------------------------------
/app/libs/arm64-v8a/libtrusty.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/arm64-v8a/libtrusty.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libbase.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libbase.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libc++.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libc++.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libcademo.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libcademo.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libcademostvels.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libcademostvels.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libcutils.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libcutils.so
--------------------------------------------------------------------------------
/app/libs/armeabi-v7a/libtrusty.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi-v7a/libtrusty.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libbase.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libbase.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libc++.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libc++.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libcademo.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libcademo.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libcademostvels.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libcademostvels.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libcutils.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libcutils.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libtrusty.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/libs/armeabi/libtrusty.so
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/revo/aesrsa/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.revo.fuckdemo", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/JniUtil.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/java/com/revo/aesrsa/JniUtil.class
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/JniUtil.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa;
2 |
3 | public class JniUtil {
4 |
5 | static {
6 | System.loadLibrary("JniUtil");
7 | }
8 |
9 | //定义一个方法,该方法在C中实现
10 | public native String getString(); //native关键字指示以原生形式实现的方法.向编译器告知实现在原生库中
11 |
12 | public native int add(int i, int j);
13 | public native String encrypt(String plainText);
14 | public native String decrypt(String cipherText);
15 |
16 | public native String getKeyValue();
17 | public native String getIv();
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 | import com.revo.aesrsa.resrsa.AES;
12 | import com.revo.aesrsa.resrsa.AesUtils;
13 | import com.revo.aesrsa.resrsa.RSA;
14 |
15 | public class MainActivity extends AppCompatActivity {
16 | Button button,enbtn,debtn;
17 | TextView tv;
18 | private JniUtil jniUtil;
19 | private String ming = "woshiyigemingwen";
20 | private String encrypmi,decrypmi;
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 | button = findViewById(R.id.button);
26 | enbtn = findViewById(R.id.button_encrpty);
27 | debtn = findViewById(R.id.button_decrpty);
28 | tv = findViewById(R.id.tv);
29 |
30 |
31 |
32 | jniUtil = new JniUtil();
33 | button.setOnClickListener(new View.OnClickListener() {
34 | @Override
35 | public void onClick(View view) {
36 | tv.setText("获取key:"+ jniUtil.getKeyValue());
37 | }
38 | });
39 |
40 | enbtn.setOnClickListener(new View.OnClickListener(){
41 |
42 | @Override
43 | public void onClick(View v) {
44 | encrypmi = jniUtil.encrypt(ming);
45 | Log.e("fuckdemo","JNI加密AES256--base64后:"+ encrypmi);
46 | tv.setText("加密后:"+ encrypmi);
47 | }
48 | });
49 |
50 | debtn.setOnClickListener(new View.OnClickListener(){
51 |
52 | @Override
53 | public void onClick(View v) {
54 | decrypmi = jniUtil.decrypt(encrypmi);
55 | Log.e("fuckdemo","JNI解密AES256--base64后:"+ decrypmi);
56 | tv.setText("解密后:"+ decrypmi);
57 | }
58 | });
59 |
60 |
61 | tv.setText("\n加密前:" + ming );
62 |
63 | //java加解密
64 |
65 | String encyptdateStr = AES.encryptToBase64(ming, jniUtil.getKeyValue().substring(0,16), jniUtil.getIv());
66 |
67 | Log.e("fuckdemo","java加密AES128--base64后:"+ encyptdateStr);
68 |
69 | String decyptdateStr = AES.decryptFromBase64(encyptdateStr, jniUtil.getKeyValue().substring(0,16), jniUtil.getIv());
70 | Log.e("fuckdemo","java解密AES128--base64后:"+ decyptdateStr);
71 |
72 |
73 |
74 |
75 | String javaEncrypt= AesUtils.aesEncrypt(ming, jniUtil.getKeyValue(), jniUtil.getIv());
76 | Log.e("fuckdemo","java解密AES256--base64后:"+ javaEncrypt);
77 | String javaDecrypt = AesUtils.aesDecrypt(javaEncrypt, jniUtil.getKeyValue(), jniUtil.getIv());
78 | Log.e("fuckdemo","java解密AES256--base64后:"+ javaDecrypt);
79 | String ncrypt_AESKey = RSA.encrypt(jniUtil.getKeyValue(),RSA.serverPublicKey);
80 | RSA.decrypt(ncrypt_AESKey,RSA.serverPrivateKey);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/AES.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.security.Key;
5 | import java.security.NoSuchAlgorithmException;
6 | import java.security.SecureRandom;
7 |
8 | import javax.crypto.Cipher;
9 | import javax.crypto.KeyGenerator;
10 | import javax.crypto.spec.IvParameterSpec;
11 | import javax.crypto.spec.SecretKeySpec;
12 |
13 | /**
14 | * Description:
15 | *
16 | * @author: stvelzhang
17 | * @date: 2020/7/21 15:12
18 | */
19 | public class AES {
20 |
21 | /**
22 | * 加密
23 | *
24 | * @param data 需要加密的内容
25 | * @param key 加密密码
26 | * @return
27 | */
28 | public static byte[] encrypt(byte[] data, byte[] key) {
29 | CheckUtils.notEmpty(data, "data");
30 | CheckUtils.notEmpty(key, "key");
31 | if (key.length != 16) {
32 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
33 | }
34 | try {
35 | SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
36 | byte[] enCodeFormat = secretKey.getEncoded();
37 | SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
38 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);// 创建密码器
39 | IvParameterSpec iv = new IvParameterSpec(key);//使用CBC模式,需要一个向量iv,可增加加密算法的强度
40 | cipher.init(Cipher.ENCRYPT_MODE, seckey, iv);// 初始化
41 | byte[] result = cipher.doFinal(data);
42 | return result; // 加密
43 | } catch (Exception e) {
44 | e.printStackTrace();
45 | throw new RuntimeException("encrypt fail!", e);
46 | }
47 | }
48 |
49 | public static byte[] encrypt(byte[] data, byte[] key,byte[] ivparm) {
50 | CheckUtils.notEmpty(data, "data");
51 | CheckUtils.notEmpty(ivparm, "key");
52 | if (key.length != 16) {
53 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
54 | }
55 | if (ivparm.length != 16) {
56 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
57 | }
58 | try {
59 | SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
60 | byte[] enCodeFormat = secretKey.getEncoded();
61 | SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
62 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);// 创建密码器
63 | IvParameterSpec iv = new IvParameterSpec(ivparm);//使用CBC模式,需要一个向量iv,可增加加密算法的强度
64 | cipher.init(Cipher.ENCRYPT_MODE, seckey, iv);// 初始化
65 | byte[] result = cipher.doFinal(data);
66 | return result; // 加密
67 | } catch (Exception e) {
68 | e.printStackTrace();
69 | throw new RuntimeException("encrypt fail!", e);
70 | }
71 | }
72 |
73 | /**
74 | * 解密
75 | *
76 | * @param data 待解密内容
77 | * @param key 解密密钥
78 | * @return
79 | */
80 | public static byte[] decrypt(byte[] data, byte[] key,byte[] ivparm) {
81 | CheckUtils.notEmpty(data, "data");
82 | CheckUtils.notEmpty(key, "key");
83 | if (key.length != 16) {
84 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
85 | }
86 | if (ivparm.length != 16) {
87 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
88 | }
89 | try {
90 | SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
91 | byte[] enCodeFormat = secretKey.getEncoded();
92 | SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
93 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);// 创建密码器
94 | IvParameterSpec iv = new IvParameterSpec(ivparm);//使用CBC模式,需要一个向量iv,可增加加密算法的强度
95 | cipher.init(Cipher.DECRYPT_MODE, seckey, iv);// 初始化
96 | byte[] result = cipher.doFinal(data);
97 | return result; // 解密
98 | } catch (Exception e) {
99 | e.printStackTrace();
100 | throw new RuntimeException("decrypt fail!", e);
101 | }
102 | }
103 |
104 | public static byte[] decrypt(byte[] data, byte[] key) {
105 | CheckUtils.notEmpty(data, "data");
106 | CheckUtils.notEmpty(key, "key");
107 | if (key.length != 16) {
108 | throw new RuntimeException("Invalid AES key length (must be 16 bytes)");
109 | }
110 | try {
111 | SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
112 | byte[] enCodeFormat = secretKey.getEncoded();
113 | SecretKeySpec seckey = new SecretKeySpec(enCodeFormat, "AES");
114 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);// 创建密码器
115 | IvParameterSpec iv = new IvParameterSpec(key);//使用CBC模式,需要一个向量iv,可增加加密算法的强度
116 | cipher.init(Cipher.DECRYPT_MODE, seckey, iv);// 初始化
117 | byte[] result = cipher.doFinal(data);
118 | return result; // 解密
119 | } catch (Exception e) {
120 | e.printStackTrace();
121 | throw new RuntimeException("decrypt fail!", e);
122 | }
123 | }
124 |
125 |
126 | public static String encryptToBase64(String data, String key) {
127 | try {
128 | byte[] valueByte = encrypt(data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING), key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
129 | return new String(Base64.encode(valueByte));
130 | } catch (UnsupportedEncodingException e) {
131 | throw new RuntimeException("encrypt fail!", e);
132 | }
133 |
134 | }
135 |
136 | public static String encryptToBase64(String data, String key,String iv) {
137 | try {
138 | byte[] valueByte = encrypt(data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING), key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING), iv.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
139 | return new String(Base64.encode(valueByte));
140 | } catch (UnsupportedEncodingException e) {
141 | throw new RuntimeException("encrypt fail!", e);
142 | }
143 |
144 | }
145 |
146 |
147 | public static String decryptFromBase64(String data, String key) {
148 | try {
149 | byte[] originalData = Base64.decode(data.getBytes());
150 | byte[] valueByte = decrypt(originalData, key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
151 | return new String(valueByte, ConfigureEncryptAndDecrypt.CHAR_ENCODING);
152 | } catch (UnsupportedEncodingException e) {
153 | throw new RuntimeException("decrypt fail!", e);
154 | }
155 | }
156 | public static String decryptFromBase64(String data, String key,String iv) {
157 | try {
158 | byte[] originalData = Base64.decode(data.getBytes());
159 | byte[] valueByte = decrypt(originalData, key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING),iv.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
160 | return new String(valueByte, ConfigureEncryptAndDecrypt.CHAR_ENCODING);
161 | } catch (UnsupportedEncodingException e) {
162 | throw new RuntimeException("decrypt fail!", e);
163 | }
164 | }
165 |
166 | public static String encryptWithKeyBase64(String data, String key) {
167 | try {
168 | byte[] valueByte = encrypt(data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING), Base64.decode(key.getBytes()));
169 | return new String(Base64.encode(valueByte));
170 | } catch (UnsupportedEncodingException e) {
171 | throw new RuntimeException("encrypt fail!", e);
172 | }
173 | }
174 |
175 | public static String decryptWithKeyBase64(String data, String key) {
176 | try {
177 | byte[] originalData = Base64.decode(data.getBytes());
178 | byte[] valueByte = decrypt(originalData, Base64.decode(key.getBytes()));
179 | return new String(valueByte, ConfigureEncryptAndDecrypt.CHAR_ENCODING);
180 | } catch (UnsupportedEncodingException e) {
181 | throw new RuntimeException("decrypt fail!", e);
182 | }
183 | }
184 |
185 | public static byte[] genarateRandomKey() {
186 | KeyGenerator keygen = null;
187 | try {
188 | keygen = KeyGenerator.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);
189 | } catch (NoSuchAlgorithmException e) {
190 | throw new RuntimeException(" genarateRandomKey fail!", e);
191 | }
192 | SecureRandom random = new SecureRandom();
193 | keygen.init(random);
194 | Key key = keygen.generateKey();
195 | return key.getEncoded();
196 | }
197 |
198 | public static String genarateRandomKeyWithBase64() {
199 | return new String(Base64.encode(genarateRandomKey()));
200 | }
201 |
202 | }
203 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/AesUtils.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.security.InvalidAlgorithmParameterException;
5 | import java.security.InvalidKeyException;
6 | import java.security.NoSuchAlgorithmException;
7 |
8 | import javax.crypto.BadPaddingException;
9 | import javax.crypto.Cipher;
10 | import javax.crypto.IllegalBlockSizeException;
11 | import javax.crypto.NoSuchPaddingException;
12 | import javax.crypto.spec.IvParameterSpec;
13 | import javax.crypto.spec.SecretKeySpec;
14 |
15 | public class AesUtils {
16 | public static final String bm = "utf-8";
17 | /**
18 | * 字节数组转化为大写16进制字符串
19 | *
20 | * @param b
21 | * @return
22 | */
23 | private static String byte2HexStr(byte[] b) {
24 | StringBuilder sb = new StringBuilder();
25 | for (int i = 0; i < b.length; i++) {
26 | String s = Integer.toHexString(b[i] & 0xFF);
27 | if (s.length() == 1) {
28 | sb.append("0");
29 | }
30 |
31 | sb.append(s.toUpperCase());
32 | }
33 |
34 | return sb.toString();
35 | }
36 |
37 | /**
38 | * 16进制字符串转字节数组
39 | *
40 | * @param s
41 | * @return
42 | */
43 | private static byte[] str2ByteArray(String s) {
44 | int byteArrayLength = s.length() / 2;
45 | byte[] b = new byte[byteArrayLength];
46 | for (int i = 0; i < byteArrayLength; i++) {
47 | byte b0 = (byte) Integer.valueOf(s.substring(i * 2, i * 2 + 2), 16)
48 | .intValue();
49 | b[i] = b0;
50 | }
51 |
52 | return b;
53 | }
54 |
55 |
56 | /**
57 | * AES 加密
58 | *
59 | * @param content
60 | * 明文
61 | * @param password
62 | * 生成秘钥的关键字
63 | * @return
64 | */
65 |
66 | public static String aesEncrypt(String content, String password,String ivparm) {
67 | try {
68 | IvParameterSpec zeroIv = new IvParameterSpec(ivparm.getBytes());
69 | SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
70 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
71 | cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);
72 | byte[] encryptedData = cipher.doFinal(content.getBytes(bm));
73 |
74 | return new String(Base64.encode(encryptedData));
75 | //return Base64ex.encode(encryptedData);
76 | // return byte2HexStr(encryptedData);
77 | } catch (NoSuchAlgorithmException e) {
78 | e.printStackTrace();
79 | } catch (NoSuchPaddingException e) {
80 | e.printStackTrace();
81 | } catch (UnsupportedEncodingException e) {
82 | e.printStackTrace();
83 | } catch (InvalidKeyException e) {
84 | e.printStackTrace();
85 | } catch (IllegalBlockSizeException e) {
86 | e.printStackTrace();
87 | } catch (BadPaddingException e) {
88 | e.printStackTrace();
89 | } catch (InvalidAlgorithmParameterException e) {
90 | e.printStackTrace();
91 | }
92 | return null;
93 | }
94 |
95 | /**
96 | * AES 解密
97 | *
98 | * @param content
99 | * 密文
100 | * @param password
101 | * 生成秘钥的关键字
102 | * @return
103 | */
104 |
105 | public static String aesDecrypt(String content, String password,String ivparm) {
106 | try {
107 | byte[] byteMi = Base64.decode(content.getBytes());
108 | //byte[] byteMi = Base64ex.decode(content);
109 | // byte[] byteMi= str2ByteArray(content);
110 | IvParameterSpec zeroIv = new IvParameterSpec(ivparm.getBytes());
111 | SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");
112 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
113 | cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);
114 | byte[] decryptedData = cipher.doFinal(byteMi);
115 | return new String(decryptedData, "utf-8");
116 | } catch (NoSuchAlgorithmException e) {
117 | e.printStackTrace();
118 | } catch (NoSuchPaddingException e) {
119 | e.printStackTrace();
120 | } catch (InvalidKeyException e) {
121 | e.printStackTrace();
122 | } catch (IllegalBlockSizeException e) {
123 | e.printStackTrace();
124 | } catch (BadPaddingException e) {
125 | e.printStackTrace();
126 | } catch (UnsupportedEncodingException e) {
127 | e.printStackTrace();
128 | } catch (InvalidAlgorithmParameterException e) {
129 | e.printStackTrace();
130 | }
131 | return null;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/Base64.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.io.UnsupportedEncodingException;
4 |
5 | public class Base64 {
6 | /**
7 | * Chunk size per RFC 2045 section 6.8.
8 | *
9 | *
The {@value} character limit does not count the trailing CRLF, but counts
10 | * all other characters, including any equal signs.
11 | *
12 | * @see RFC 2045 section 6.8
13 | */
14 | static final int CHUNK_SIZE = 76;
15 |
16 | /**
17 | * Chunk separator per RFC 2045 section 2.1.
18 | *
19 | * @see RFC 2045 section 2.1
20 | */
21 | static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();
22 |
23 | /**
24 | * The base length.
25 | */
26 | static final int BASELENGTH = 255;
27 |
28 | /**
29 | * Lookup length.
30 | */
31 | static final int LOOKUPLENGTH = 64;
32 |
33 | /**
34 | * Used to calculate the number of bits in a byte.
35 | */
36 | static final int EIGHTBIT = 8;
37 |
38 | /**
39 | * Used when encoding something which has fewer than 24 bits.
40 | */
41 | static final int SIXTEENBIT = 16;
42 |
43 | /**
44 | * Used to determine how many bits data contains.
45 | */
46 | static final int TWENTYFOURBITGROUP = 24;
47 |
48 | /**
49 | * Used to get the number of Quadruples.
50 | */
51 | static final int FOURBYTE = 4;
52 |
53 | /**
54 | * Used to test the sign of a byte.
55 | */
56 | static final int SIGN = -128;
57 |
58 | /**
59 | * Byte used to pad output.
60 | */
61 | static final byte PAD = (byte) '=';
62 |
63 | // Create arrays to hold the base64 characters and a
64 | // lookup for base64 chars
65 | private static byte[] base64Alphabet = new byte[BASELENGTH];
66 | private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
67 |
68 | // Populating the lookup and character arrays
69 | static {
70 | for (int i = 0; i < BASELENGTH; i++) {
71 | base64Alphabet[i] = (byte) -1;
72 | }
73 | for (int i = 'Z'; i >= 'A'; i--) {
74 | base64Alphabet[i] = (byte) (i - 'A');
75 | }
76 | for (int i = 'z'; i >= 'a'; i--) {
77 | base64Alphabet[i] = (byte) (i - 'a' + 26);
78 | }
79 | for (int i = '9'; i >= '0'; i--) {
80 | base64Alphabet[i] = (byte) (i - '0' + 52);
81 | }
82 |
83 | base64Alphabet['+'] = 62;
84 | base64Alphabet['/'] = 63;
85 |
86 | for (int i = 0; i <= 25; i++) {
87 | lookUpBase64Alphabet[i] = (byte) ('A' + i);
88 | }
89 |
90 | for (int i = 26, j = 0; i <= 51; i++, j++) {
91 | lookUpBase64Alphabet[i] = (byte) ('a' + j);
92 | }
93 |
94 | for (int i = 52, j = 0; i <= 61; i++, j++) {
95 | lookUpBase64Alphabet[i] = (byte) ('0' + j);
96 | }
97 |
98 | lookUpBase64Alphabet[62] = (byte) '+';
99 | lookUpBase64Alphabet[63] = (byte) '/';
100 | }
101 |
102 | private static boolean isBase64(byte octect) {
103 | if (octect == PAD) {
104 | return true;
105 | } else if (base64Alphabet[octect] == -1) {
106 | return false;
107 | } else {
108 | return true;
109 | }
110 | }
111 |
112 | /**
113 | * Tests a given byte array to see if it contains
114 | * only valid characters within the Base64 alphabet.
115 | *
116 | * @param arrayOctect byte array to test
117 | * @return true if all bytes are valid characters in the Base64
118 | * alphabet or if the byte array is empty; false, otherwise
119 | */
120 | public static boolean isArrayByteBase64(byte[] arrayOctect) {
121 |
122 | arrayOctect = discardWhitespace(arrayOctect);
123 |
124 | int length = arrayOctect.length;
125 | if (length == 0) {
126 | // shouldn't a 0 length array be valid base64 data?
127 | // return false;
128 | return true;
129 | }
130 | for (int i = 0; i < length; i++) {
131 | if (!isBase64(arrayOctect[i])) {
132 | return false;
133 | }
134 | }
135 | return true;
136 | }
137 |
138 | /**
139 | * Encodes binary data using the base64 algorithm but
140 | * does not chunk the output.
141 | *
142 | * @param binaryData binary data to encode
143 | * @return Base64 characters
144 | */
145 | public static byte[] encodeBase64(byte[] binaryData) {
146 | return encodeBase64(binaryData, false);
147 | }
148 |
149 | /**
150 | * Encodes binary data using the base64 algorithm and chunks
151 | * the encoded output into 76 character blocks
152 | *
153 | * @param binaryData binary data to encode
154 | * @return Base64 characters chunked in 76 character blocks
155 | */
156 | public static byte[] encodeBase64Chunked(byte[] binaryData) {
157 | return encodeBase64(binaryData, true);
158 | }
159 |
160 | /**
161 | * Decodes a byte[] containing containing
162 | * characters in the Base64 alphabet.
163 | *
164 | * @param pArray A byte array containing Base64 character data
165 | * @return a byte array containing binary data
166 | */
167 | public static byte[] decode(byte[] pArray) {
168 | return decodeBase64(pArray);
169 | }
170 |
171 | /**
172 | * Encodes binary data using the base64 algorithm, optionally
173 | * chunking the output into 76 character blocks.
174 | *
175 | * @param binaryData Array containing binary data to encode.
176 | * @param isChunked if isChunked is true this encoder will chunk
177 | * the base64 output into 76 character blocks
178 | * @return Base64-encoded data.
179 | */
180 | public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
181 | int lengthDataBits = binaryData.length * EIGHTBIT;
182 | int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
183 | int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
184 | byte encodedData[] = null;
185 | int encodedDataLength = 0;
186 | int nbrChunks = 0;
187 |
188 | if (fewerThan24bits != 0) {
189 | //data not divisible by 24 bit
190 | encodedDataLength = (numberTriplets + 1) * 4;
191 | } else {
192 | // 16 or 8 bit
193 | encodedDataLength = numberTriplets * 4;
194 | }
195 |
196 | // If the output is to be "chunked" into 76 character sections,
197 | // for compliance with RFC 2045 MIME, then it is important to
198 | // allow for extra length to account for the separator(s)
199 | if (isChunked) {
200 |
201 | nbrChunks =
202 | (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
203 | encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
204 | }
205 |
206 | encodedData = new byte[encodedDataLength];
207 |
208 | byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
209 |
210 | int encodedIndex = 0;
211 | int dataIndex = 0;
212 | int i = 0;
213 | int nextSeparatorIndex = CHUNK_SIZE;
214 | int chunksSoFar = 0;
215 |
216 | //log.debug("number of triplets = " + numberTriplets);
217 | for (i = 0; i < numberTriplets; i++) {
218 | dataIndex = i * 3;
219 | b1 = binaryData[dataIndex];
220 | b2 = binaryData[dataIndex + 1];
221 | b3 = binaryData[dataIndex + 2];
222 |
223 | //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
224 |
225 | l = (byte) (b2 & 0x0f);
226 | k = (byte) (b1 & 0x03);
227 |
228 | byte val1 =
229 | ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
230 | byte val2 =
231 | ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
232 | byte val3 =
233 | ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
234 |
235 | encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
236 | //log.debug( "val2 = " + val2 );
237 | //log.debug( "k4 = " + (k<<4) );
238 | //log.debug( "vak = " + (val2 | (k<<4)) );
239 | encodedData[encodedIndex + 1] =
240 | lookUpBase64Alphabet[val2 | (k << 4)];
241 | encodedData[encodedIndex + 2] =
242 | lookUpBase64Alphabet[(l << 2) | val3];
243 | encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
244 |
245 | encodedIndex += 4;
246 |
247 | // If we are chunking, let's put a chunk separator down.
248 | if (isChunked) {
249 | // this assumes that CHUNK_SIZE % 4 == 0
250 | if (encodedIndex == nextSeparatorIndex) {
251 | System.arraycopy(
252 | CHUNK_SEPARATOR,
253 | 0,
254 | encodedData,
255 | encodedIndex,
256 | CHUNK_SEPARATOR.length);
257 | chunksSoFar++;
258 | nextSeparatorIndex =
259 | (CHUNK_SIZE * (chunksSoFar + 1)) +
260 | (chunksSoFar * CHUNK_SEPARATOR.length);
261 | encodedIndex += CHUNK_SEPARATOR.length;
262 | }
263 | }
264 | }
265 |
266 | // form integral number of 6-bit groups
267 | dataIndex = i * 3;
268 |
269 | if (fewerThan24bits == EIGHTBIT) {
270 | b1 = binaryData[dataIndex];
271 | k = (byte) (b1 & 0x03);
272 | //log.debug("b1=" + b1);
273 | //log.debug("b1<<2 = " + (b1>>2) );
274 | byte val1 =
275 | ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
276 | encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
277 | encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
278 | encodedData[encodedIndex + 2] = PAD;
279 | encodedData[encodedIndex + 3] = PAD;
280 | } else if (fewerThan24bits == SIXTEENBIT) {
281 |
282 | b1 = binaryData[dataIndex];
283 | b2 = binaryData[dataIndex + 1];
284 | l = (byte) (b2 & 0x0f);
285 | k = (byte) (b1 & 0x03);
286 |
287 | byte val1 =
288 | ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
289 | byte val2 =
290 | ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
291 |
292 | encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
293 | encodedData[encodedIndex + 1] =
294 | lookUpBase64Alphabet[val2 | (k << 4)];
295 | encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
296 | encodedData[encodedIndex + 3] = PAD;
297 | }
298 |
299 | if (isChunked) {
300 | // we also add a separator to the end of the final chunk.
301 | if (chunksSoFar < nbrChunks) {
302 | System.arraycopy(
303 | CHUNK_SEPARATOR,
304 | 0,
305 | encodedData,
306 | encodedDataLength - CHUNK_SEPARATOR.length,
307 | CHUNK_SEPARATOR.length);
308 | }
309 | }
310 |
311 | return encodedData;
312 | }
313 |
314 | /**
315 | * Decodes Base64 data into octects
316 | *
317 | * @param base64Data Byte array containing Base64 data
318 | * @return Array containing decoded data.
319 | */
320 | public static byte[] decodeBase64(byte[] base64Data) {
321 | // RFC 2045 requires that we discard ALL non-Base64 characters
322 | base64Data = discardNonBase64(base64Data);
323 |
324 | // handle the edge case, so we don't have to worry about it later
325 | if (base64Data.length == 0) {
326 | return new byte[0];
327 | }
328 |
329 | int numberQuadruple = base64Data.length / FOURBYTE;
330 | byte decodedData[] = null;
331 | byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
332 |
333 | // Throw away anything not in base64Data
334 |
335 | int encodedIndex = 0;
336 | int dataIndex = 0;
337 | {
338 | // this sizes the output array properly - rlw
339 | int lastData = base64Data.length;
340 | // ignore the '=' padding
341 | while (base64Data[lastData - 1] == PAD) {
342 | if (--lastData == 0) {
343 | return new byte[0];
344 | }
345 | }
346 | decodedData = new byte[lastData - numberQuadruple];
347 | }
348 |
349 | for (int i = 0; i < numberQuadruple; i++) {
350 | dataIndex = i * 4;
351 | marker0 = base64Data[dataIndex + 2];
352 | marker1 = base64Data[dataIndex + 3];
353 |
354 | b1 = base64Alphabet[base64Data[dataIndex]];
355 | b2 = base64Alphabet[base64Data[dataIndex + 1]];
356 |
357 | if (marker0 != PAD && marker1 != PAD) {
358 | //No PAD e.g 3cQl
359 | b3 = base64Alphabet[marker0];
360 | b4 = base64Alphabet[marker1];
361 |
362 | decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
363 | decodedData[encodedIndex + 1] =
364 | (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
365 | decodedData[encodedIndex + 2] = (byte) (b3 << 6 | b4);
366 | } else if (marker0 == PAD) {
367 | //Two PAD e.g. 3c[Pad][Pad]
368 | decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
369 | } else if (marker1 == PAD) {
370 | //One PAD e.g. 3cQ[Pad]
371 | b3 = base64Alphabet[marker0];
372 |
373 | decodedData[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
374 | decodedData[encodedIndex + 1] =
375 | (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
376 | }
377 | encodedIndex += 3;
378 | }
379 | return decodedData;
380 | }
381 |
382 | /**
383 | * Discards any whitespace from a base-64 encoded block.
384 | *
385 | * @param data The base-64 encoded data to discard the whitespace
386 | * from.
387 | * @return The data, less whitespace (see RFC 2045).
388 | */
389 | static byte[] discardWhitespace(byte[] data) {
390 | byte groomedData[] = new byte[data.length];
391 | int bytesCopied = 0;
392 |
393 | for (int i = 0; i < data.length; i++) {
394 | switch (data[i]) {
395 | case (byte) ' ' :
396 | case (byte) '\n' :
397 | case (byte) '\r' :
398 | case (byte) '\t' :
399 | break;
400 | default:
401 | groomedData[bytesCopied++] = data[i];
402 | }
403 | }
404 |
405 | byte packedData[] = new byte[bytesCopied];
406 |
407 | System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
408 |
409 | return packedData;
410 | }
411 |
412 | /**
413 | * Discards any characters outside of the base64 alphabet, per
414 | * the requirements on page 25 of RFC 2045 - "Any characters
415 | * outside of the base64 alphabet are to be ignored in base64
416 | * encoded data."
417 | *
418 | * @param data The base-64 encoded data to groom
419 | * @return The data, less non-base64 characters (see RFC 2045).
420 | */
421 | static byte[] discardNonBase64(byte[] data) {
422 | byte groomedData[] = new byte[data.length];
423 | int bytesCopied = 0;
424 |
425 | for (int i = 0; i < data.length; i++) {
426 | if (isBase64(data[i])) {
427 | groomedData[bytesCopied++] = data[i];
428 | }
429 | }
430 |
431 | byte packedData[] = new byte[bytesCopied];
432 |
433 | System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
434 |
435 | return packedData;
436 | }
437 |
438 | /**
439 | * Encodes a byte[] containing binary data, into a byte[] containing
440 | * characters in the Base64 alphabet.
441 | *
442 | * @param pArray a byte array containing binary data
443 | * @return A byte array containing only Base64 character data
444 | */
445 | public static byte[] encode(byte[] pArray) {
446 | return encodeBase64(pArray, false);
447 | }
448 |
449 | public static String encode(String str) throws UnsupportedEncodingException
450 | {
451 | String baseStr = new String(encode(str.getBytes("UTF-8")));
452 | String tempStr = Digest.digest(str).toUpperCase();
453 | String result = tempStr+baseStr;
454 | return new String(encode(result.getBytes("UTF-8")));
455 | }
456 |
457 | public static String decode(String cryptoStr) throws
458 | UnsupportedEncodingException {
459 | if(cryptoStr.length()<40)
460 | return "";
461 | try
462 | {
463 | String tempStr = new String(decode(cryptoStr.getBytes("UTF-8")));
464 | String result = tempStr.substring(40, tempStr.length());
465 | return new String(decode(result.getBytes("UTF-8")));
466 | }
467 | catch(ArrayIndexOutOfBoundsException ex)
468 | {
469 | return "";
470 | }
471 | }
472 |
473 | /**
474 | * Decodes Base64 data into octects
475 | *
476 | * @param encoded string containing Base64 data
477 | * @return Array containind decoded data.
478 | */
479 | public static byte[] decode2(String encoded) {
480 |
481 | if (encoded == null) {
482 | return null;
483 | }
484 |
485 | char[] base64Data = encoded.toCharArray();
486 | // remove white spaces
487 | int len = removeWhiteSpace(base64Data);
488 |
489 | if (len % FOURBYTE != 0) {
490 | return null;//should be divisible by four
491 | }
492 |
493 | int numberQuadruple = (len / FOURBYTE);
494 |
495 | if (numberQuadruple == 0) {
496 | return new byte[0];
497 | }
498 |
499 | byte decodedData[] = null;
500 | byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
501 | char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
502 |
503 | int i = 0;
504 | int encodedIndex = 0;
505 | int dataIndex = 0;
506 | decodedData = new byte[(numberQuadruple) * 3];
507 |
508 | for (; i < numberQuadruple - 1; i++) {
509 |
510 | if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
511 | || !isData((d3 = base64Data[dataIndex++]))
512 | || !isData((d4 = base64Data[dataIndex++]))) {
513 | return null;
514 | }//if found "no data" just return null
515 |
516 | b1 = base64Alphabet[d1];
517 | b2 = base64Alphabet[d2];
518 | b3 = base64Alphabet[d3];
519 | b4 = base64Alphabet[d4];
520 |
521 | decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
522 | decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
523 | decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
524 | }
525 |
526 | if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
527 | return null;//if found "no data" just return null
528 | }
529 |
530 | b1 = base64Alphabet[d1];
531 | b2 = base64Alphabet[d2];
532 |
533 | d3 = base64Data[dataIndex++];
534 | d4 = base64Data[dataIndex++];
535 | if (!isData((d3)) || !isData((d4))) {//Check if they are PAD characters
536 | if (isPad(d3) && isPad(d4)) {
537 | if ((b2 & 0xf) != 0)//last 4 bits should be zero
538 | {
539 | return null;
540 | }
541 | byte[] tmp = new byte[i * 3 + 1];
542 | System.arraycopy(decodedData, 0, tmp, 0, i * 3);
543 | tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
544 | return tmp;
545 | } else if (!isPad(d3) && isPad(d4)) {
546 | b3 = base64Alphabet[d3];
547 | if ((b3 & 0x3) != 0)//last 2 bits should be zero
548 | {
549 | return null;
550 | }
551 | byte[] tmp = new byte[i * 3 + 2];
552 | System.arraycopy(decodedData, 0, tmp, 0, i * 3);
553 | tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
554 | tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
555 | return tmp;
556 | } else {
557 | return null;
558 | }
559 | } else { //No PAD e.g 3cQl
560 | b3 = base64Alphabet[d3];
561 | b4 = base64Alphabet[d4];
562 | decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
563 | decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
564 | decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
565 |
566 | }
567 |
568 | return decodedData;
569 | }
570 |
571 | private static boolean isWhiteSpace(char octect) {
572 | return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
573 | }
574 |
575 | private static boolean isData(char octect) {
576 | return (octect < BASELENGTH && base64Alphabet[octect] != -1);
577 | }
578 |
579 | private static boolean isPad(char octect) {
580 | return (octect == PAD);
581 | }
582 |
583 | /**
584 | * remove WhiteSpace from MIME containing encoded Base64 data.
585 | *
586 | * @param data the byte array of base64 data (with WS)
587 | * @return the new length
588 | */
589 | private static int removeWhiteSpace(char[] data) {
590 | if (data == null) {
591 | return 0;
592 | }
593 |
594 | // count characters that's not whitespace
595 | int newSize = 0;
596 | int len = data.length;
597 | for (int i = 0; i < len; i++) {
598 | if (!isWhiteSpace(data[i])) {
599 | data[newSize++] = data[i];
600 | }
601 | }
602 | return newSize;
603 | }
604 | }
605 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/CheckUtils.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.lang.reflect.Array;
4 | import java.util.Collection;
5 | import java.util.Map;
6 |
7 |
8 | public class CheckUtils {
9 |
10 | public static final String COMMON_FIELD = "flowID,initiator,";
11 |
12 |
13 | /**
14 | * 验证对象是否为NULL,空字符串,空数组,空的Collection或Map(只有空格的字符串也认为是空串)
15 | * @param obj 被验证的对象
16 | * @param message 异常信息
17 | */
18 | @SuppressWarnings("rawtypes")
19 | public static void notEmpty(Object obj, String message) {
20 | if (obj == null){
21 | throw new IllegalArgumentException(message + " must be specified");
22 | }
23 | if (obj instanceof String && obj.toString().trim().length()==0){
24 | throw new IllegalArgumentException(message + " must be specified");
25 | }
26 | if (obj.getClass().isArray() && Array.getLength(obj)==0){
27 | throw new IllegalArgumentException(message + " must be specified");
28 | }
29 | if (obj instanceof Collection && ((Collection)obj).isEmpty()){
30 | throw new IllegalArgumentException(message + " must be specified");
31 | }
32 | if (obj instanceof Map && ((Map)obj).isEmpty()){
33 | throw new IllegalArgumentException(message + " must be specified");
34 | }
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/ConfigureEncryptAndDecrypt.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | public class ConfigureEncryptAndDecrypt {
4 | public static final String CHAR_ENCODING = "UTF-8";
5 | public static final String AES_ALGORITHM = "AES/CBC/PKCS5Padding";
6 | public static final String RSA_ALGORITHM = "RSA/ECB/PKCS1Padding";
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/ConvertUtils.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.sql.Date;
5 | import java.sql.Time;
6 | import java.sql.Timestamp;
7 | import java.text.DecimalFormat;
8 | import java.util.Calendar;
9 | import java.util.GregorianCalendar;
10 | import java.util.Locale;
11 | import java.util.TimeZone;
12 |
13 | public abstract class ConvertUtils {
14 |
15 | private static final DecimalFormat simpleFormat = new DecimalFormat("####");
16 |
17 | public static final boolean objectToBoolean(Object o){
18 | return o != null ? Boolean.valueOf(o.toString()).booleanValue() : false;
19 | }
20 |
21 | public static final int objectToInt(Object o){
22 | if(o instanceof Number)
23 | return ((Number)o).intValue();
24 | try{
25 | if(o == null)
26 | return -1;
27 | else
28 | return Integer.parseInt(o.toString());
29 | }catch(NumberFormatException e){
30 | return -1;
31 | }
32 | }
33 |
34 | public static final short objectToShort(Object o){
35 | if(o instanceof Number)
36 | return ((Number)o).shortValue();
37 | try{
38 | if(o == null)
39 | return -1;
40 | else
41 | return Short.parseShort(o.toString());
42 | }catch(NumberFormatException e){
43 | return -1;
44 | }
45 | }
46 |
47 | public static final double objectToDouble(Object o){
48 | if(o instanceof Number)
49 | return ((Number)o).doubleValue();
50 | try{
51 | if(o == null)
52 | return -1D;
53 | else
54 | return Double.parseDouble(o.toString());
55 | }catch(NumberFormatException e){
56 | return -1D;
57 | }
58 | }
59 |
60 | public static final long objectToLong(Object o)
61 | {
62 | if(o instanceof Number)
63 | return ((Number)o).longValue();
64 | try{
65 | if(o == null)
66 | return -1L;
67 | else
68 | return Long.parseLong(o.toString());
69 | }catch(NumberFormatException e){
70 | return -1L;
71 | }
72 | }
73 |
74 | public static final String objectToString(Object obj, DecimalFormat fmt)
75 | {
76 | fmt.setDecimalSeparatorAlwaysShown(false);
77 | if(obj instanceof Double)
78 | return fmt.format(((Double)obj).doubleValue());
79 | if(obj instanceof Long)
80 | return fmt.format(((Long)obj).longValue());
81 | else
82 | return obj.toString();
83 | }
84 |
85 | public static final Object getObjectValue(String value)
86 | {
87 | try{
88 | return Long.valueOf(value);
89 | }catch(NumberFormatException e) {}
90 |
91 | try{
92 | return Double.valueOf(value);
93 | }catch(NumberFormatException e){
94 | return value;
95 | }
96 | }
97 |
98 | public static String longToSimpleString(long value){
99 | return simpleFormat.format(value);
100 | }
101 |
102 | public static String asHex(byte hash[]){
103 | return toHex(hash);
104 | }
105 |
106 | public static String toHex(byte input[]){
107 | if(input == null)
108 | return null;
109 | StringBuffer output = new StringBuffer(input.length * 2);
110 | for(int i = 0; i < input.length; i++){
111 | int current = input[i] & 0xff;
112 | if(current < 16)
113 | output.append("0");
114 | output.append(Integer.toString(current, 16));
115 | }
116 |
117 | return output.toString();
118 | }
119 |
120 | public static byte[] fromHex(String input){
121 | if(input == null)
122 | return null;
123 | byte output[] = new byte[input.length() / 2];
124 | for(int i = 0; i < output.length; i++)
125 | output[i] = (byte)Integer.parseInt(input.substring(i * 2, (i + 1) * 2), 16);
126 |
127 | return output;
128 | }
129 |
130 | public static String stringToHexString(String input, String encoding)
131 | throws UnsupportedEncodingException{
132 | return input != null ? toHex(input.getBytes(encoding)) : null;
133 | }
134 |
135 | public static String stringToHexString(String input){
136 | try{
137 | return stringToHexString(input, "UTF-8");
138 | }catch(UnsupportedEncodingException e){
139 | throw new IllegalStateException("UTF-8 encoding is not supported by JVM");
140 | }
141 | }
142 |
143 | public static String hexStringToString(String input, String encoding)
144 | throws UnsupportedEncodingException{
145 | return input != null ? new String(fromHex(input), encoding) : null;
146 | }
147 |
148 | public static String hexStringToString(String input){
149 | try{
150 | return hexStringToString(input, "UTF-8");
151 | }catch(UnsupportedEncodingException e){
152 | throw new IllegalStateException("UTF-8 encoding is not supported by JVM");
153 | }
154 | }
155 |
156 | public static String timeZoneToCode(TimeZone tz){
157 |
158 | return timeZoneToString(tz);
159 | }
160 |
161 | public static TimeZone codeToTimeZone(String tzString){
162 |
163 | return stringToTimeZone(tzString);
164 | }
165 |
166 | public static String timeZoneToString(TimeZone tz){
167 |
168 | return tz != null ? tz.getID() : "";
169 | }
170 |
171 | public static TimeZone stringToTimeZone(String tzString){
172 |
173 | return TimeZone.getTimeZone(tzString != null ? tzString : "");
174 | }
175 |
176 | public static String localeToCode(Locale aLocale){
177 |
178 | return localeToString(aLocale);
179 | }
180 |
181 | public static Locale codeToLocale(String locString){
182 |
183 | return stringToLocale(locString);
184 | }
185 |
186 | public static String localeToString(Locale loc){
187 |
188 | return loc != null ? loc.toString() : "";
189 | }
190 |
191 | public static Locale stringToLocale(String locString){
192 |
193 | locString = locString != null ? locString.trim() : "";
194 | if(locString.equals(""))
195 | return new Locale("", "", "");
196 | int pos = locString.indexOf(95);
197 | if(pos == -1)
198 | return new Locale(locString, "", "");
199 | String language = locString.substring(0, pos);
200 | locString = locString.substring(pos + 1);
201 | pos = locString.indexOf(95);
202 | if(pos == -1){
203 | return new Locale(language, locString, "");
204 | }else{
205 | String country = locString.substring(0, pos);
206 | locString = locString.substring(pos + 1);
207 | return new Locale(language, country, locString);
208 | }
209 | }
210 |
211 | public static Date dateToSQLDate(java.util.Date d){
212 |
213 | return d != null ? new Date(d.getTime()) : null;
214 | }
215 |
216 | public static Time dateToSQLTime(java.util.Date d){
217 |
218 | return d != null ? new Time(d.getTime()) : null;
219 | }
220 |
221 | public static Timestamp dateToSQLTimestamp(java.util.Date d){
222 |
223 | return d != null ? new Timestamp(d.getTime()) : null;
224 | }
225 |
226 | public static java.util.Date sqlTimestampToDate(Timestamp t){
227 |
228 | return t != null ? new java.util.Date(Math.round((double)t.getTime() + (double)t.getNanos() / 1000000D)) : null;
229 | }
230 |
231 | public static Timestamp getCurrentDate(){
232 |
233 | Calendar c = Calendar.getInstance();
234 | c.set(c.get(1), c.get(2), c.get(5), 0, 0, 0);
235 | Timestamp t = new Timestamp(c.getTime().getTime());
236 | t.setNanos(0);
237 | return t;
238 | }
239 |
240 | public static java.util.Date getDate(int y, int m, int d, boolean inclusive)
241 | {
242 | java.util.Date dt = null;
243 | Calendar c = Calendar.getInstance();
244 | c.clear();
245 | if(c.getActualMinimum(1) <= y && y <= c.getActualMaximum(1))
246 | {
247 | c.set(1, y);
248 | if(c.getActualMinimum(2) <= m && m <= c.getActualMaximum(2))
249 | {
250 | c.set(2, m);
251 | if(c.getActualMinimum(5) <= d && d <= c.getActualMaximum(5))
252 | c.set(5, d);
253 | }
254 | if(inclusive)
255 | {
256 | c.add(5, 1);
257 | c.add(14, -1);
258 | }
259 | dt = c.getTime();
260 | }
261 | return dt;
262 | }
263 |
264 | public static java.util.Date getDateStart(java.util.Date d)
265 | {
266 |
267 | Calendar c = new GregorianCalendar();
268 | c.clear();
269 | Calendar co = new GregorianCalendar();
270 | co.setTime(d);
271 | c.set(Calendar.DAY_OF_MONTH,co.get(Calendar.DAY_OF_MONTH));
272 | c.set(Calendar.MONTH,co.get(Calendar.MONTH));
273 | c.set(Calendar.YEAR,co.get(Calendar.YEAR));
274 | //c.add(Calendar.DAY_OF_MONTH,1);
275 | //c.add(Calendar.MILLISECOND,-1);
276 | return c.getTime();
277 | }
278 |
279 | public static java.util.Date getDateEnd(java.util.Date d)
280 | {
281 | Calendar c = Calendar.getInstance();
282 | c.clear();
283 | Calendar co = Calendar.getInstance();
284 | co.setTime(d);
285 | c.set(Calendar.DAY_OF_MONTH,co.get(Calendar.DAY_OF_MONTH));
286 | c.set(Calendar.MONTH,co.get(Calendar.MONTH));
287 | c.set(Calendar.YEAR,co.get(Calendar.YEAR));
288 | c.add(Calendar.DAY_OF_MONTH,1);
289 | c.add(Calendar.MILLISECOND,-1);
290 | return c.getTime();
291 | }
292 |
293 | public static double roundNumber(double rowNumber, int roundingPoint)
294 | {
295 | double base = Math.pow(10D, roundingPoint);
296 | return (double)Math.round(rowNumber * base) / base;
297 | }
298 | public static Object getObject(String type,String value) throws Exception{
299 |
300 | type=type.toLowerCase();
301 | if("boolean".equals(type))
302 | return Boolean.valueOf(value);
303 | if("byte".equals(type))
304 | return Byte.valueOf(value);
305 | if("short".equals(type))
306 | return Short.valueOf(value);
307 | if("char".equals(type))
308 | if(value.length() != 1)
309 | throw new NumberFormatException("Argument is not a character!");
310 | else
311 | return Character.valueOf(value.toCharArray()[0]);
312 | if("int".equals(type))
313 | return Integer.valueOf(value);
314 | if("long".equals(type))
315 | return Long.valueOf(value);
316 | if("float".equals(type))
317 | return Float.valueOf(value);
318 | if("double".equals(type))
319 | return Double.valueOf(value);
320 | if("string".equals(type))
321 | return value;
322 | else{
323 | Object objs[]=new String[]{value};
324 | return Class.forName(type).getConstructor(new Class[] {
325 | String.class
326 | }).newInstance(objs);
327 | }
328 | }
329 | private ConvertUtils(){}
330 |
331 | // public static void main(String[] args)
332 | // {
333 | // System.out.println(getDateStart(new java.util.Date()));
334 | // }
335 | }
336 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/Digest.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.UnsupportedEncodingException;
6 | import java.security.MessageDigest;
7 | import java.security.NoSuchAlgorithmException;
8 | import java.util.Arrays;
9 |
10 |
11 | public class Digest {
12 | private static final String TAG = "revoaesrsa";
13 | public static final String ENCODE = "UTF-8";
14 |
15 | public static String signMD5(String aValue, String encoding) {
16 | try {
17 | byte[] input = aValue.getBytes(encoding);
18 | MessageDigest md = MessageDigest.getInstance("MD5");
19 | return ConvertUtils.toHex(md.digest(input));
20 | } catch (NoSuchAlgorithmException e) {
21 | Log.e(TAG,"signMD5---error:" + e + "--message:" + e.getMessage());
22 |
23 | return null;
24 | } catch (UnsupportedEncodingException e) {
25 | Log.e(TAG,"signMD5---error:" + e + "--message:" + e.getMessage());
26 | return null;
27 | }
28 | }
29 |
30 | public static String hmacSign(String aValue) {
31 | try {
32 | byte[] input = aValue.getBytes();
33 | MessageDigest md = MessageDigest.getInstance("MD5");
34 | return ConvertUtils.toHex(md.digest(input));
35 | } catch (NoSuchAlgorithmException e) {
36 | Log.e(TAG,"hmacSign---error:" + e + "--message:" + e.getMessage());
37 | return null;
38 | }
39 | }
40 |
41 | public static String hmacSign(String aValue, String aKey) {
42 | return hmacSign(aValue, aKey, ENCODE);
43 | }
44 |
45 | public static String hmacSign(String aValue, String aKey, String encoding) {
46 | byte k_ipad[] = new byte[64];
47 | byte k_opad[] = new byte[64];
48 | byte keyb[];
49 | byte value[];
50 | try {
51 | keyb = aKey.getBytes(encoding);
52 | value = aValue.getBytes(encoding);
53 | } catch (UnsupportedEncodingException e) {
54 | keyb = aKey.getBytes();
55 | value = aValue.getBytes();
56 | }
57 | Arrays.fill(k_ipad, keyb.length, 64, (byte) 54);
58 | Arrays.fill(k_opad, keyb.length, 64, (byte) 92);
59 | for (int i = 0; i < keyb.length; i++) {
60 | k_ipad[i] = (byte) (keyb[i] ^ 0x36);
61 | k_opad[i] = (byte) (keyb[i] ^ 0x5c);
62 | }
63 |
64 | MessageDigest md = null;
65 | try {
66 | md = MessageDigest.getInstance("MD5");
67 | } catch (NoSuchAlgorithmException e) {
68 | Log.e(TAG,"hmacSign---error:" + e + "--message:" + e.getMessage());
69 | return null;
70 | }
71 | md.update(k_ipad);
72 | md.update(value);
73 | byte dg[] = md.digest();
74 | md.reset();
75 | md.update(k_opad);
76 | md.update(dg, 0, 16);
77 | dg = md.digest();
78 | return ConvertUtils.toHex(dg);
79 | }
80 |
81 | public static String hmacSHASign(String aValue, String aKey, String encoding) {
82 | byte k_ipad[] = new byte[64];
83 | byte k_opad[] = new byte[64];
84 | byte keyb[];
85 | byte value[];
86 | try {
87 | keyb = aKey.getBytes(encoding);
88 | value = aValue.getBytes(encoding);
89 | } catch (UnsupportedEncodingException e) {
90 | keyb = aKey.getBytes();
91 | value = aValue.getBytes();
92 | }
93 | Arrays.fill(k_ipad, keyb.length, 64, (byte) 54);
94 | Arrays.fill(k_opad, keyb.length, 64, (byte) 92);
95 | for (int i = 0; i < keyb.length; i++) {
96 | k_ipad[i] = (byte) (keyb[i] ^ 0x36);
97 | k_opad[i] = (byte) (keyb[i] ^ 0x5c);
98 | }
99 |
100 | MessageDigest md = null;
101 | try {
102 | md = MessageDigest.getInstance("SHA");
103 | } catch (NoSuchAlgorithmException e) {
104 | Log.e(TAG,"hmacSHASign---error:" + e + "--message:" + e.getMessage());
105 | return null;
106 | }
107 | md.update(k_ipad);
108 | md.update(value);
109 | byte dg[] = md.digest();
110 | md.reset();
111 | md.update(k_opad);
112 | md.update(dg, 0, 20);
113 | dg = md.digest();
114 | return ConvertUtils.toHex(dg);
115 | }
116 |
117 | public static String digest(String aValue) {
118 | return digest(aValue, ENCODE);
119 |
120 | }
121 |
122 | public static String digest(String aValue, String encoding) {
123 | aValue = aValue.trim();
124 | byte value[];
125 | try {
126 | value = aValue.getBytes(encoding);
127 | } catch (UnsupportedEncodingException e) {
128 | value = aValue.getBytes();
129 | }
130 | MessageDigest md = null;
131 | try {
132 | md = MessageDigest.getInstance("SHA");
133 | } catch (NoSuchAlgorithmException e) {
134 | Log.e(TAG,"digest---error:" + e + "--message:" + e.getMessage());
135 | return null;
136 | }
137 | return ConvertUtils.toHex(md.digest(value));
138 | }
139 |
140 |
141 | public static String digest(String aValue, String alg, String encoding) {
142 | aValue = aValue.trim();
143 | byte value[];
144 | try {
145 | value = aValue.getBytes(encoding);
146 | } catch (UnsupportedEncodingException e) {
147 | value = aValue.getBytes();
148 | }
149 | MessageDigest md = null;
150 | try {
151 | md = MessageDigest.getInstance(alg);
152 | } catch (NoSuchAlgorithmException e) {
153 | Log.e(TAG,"digest---error:" + e + "--message:" + e.getMessage());
154 | return null;
155 | }
156 | return ConvertUtils.toHex(md.digest(value));
157 | }
158 |
159 | public static String udpSign(String aValue) {
160 | try {
161 | byte[] input = aValue.getBytes("UTF-8");
162 | MessageDigest md = MessageDigest.getInstance("SHA1");
163 | return new String(Base64.encode(md.digest(input)), ENCODE);
164 | } catch (Exception e) {
165 | return null;
166 | }
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/EncryUtil.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.util.Map.Entry;
4 | import java.util.TreeMap;
5 |
6 |
7 | public class EncryUtil {
8 | private static final String TAG = "revoaesrsa";
9 | /**
10 | * 生成RSA签名
11 | */
12 | public static String handleRSA(TreeMap map,
13 | String privateKey) {
14 | StringBuffer sbuffer = new StringBuffer();
15 | for (Entry entry : map.entrySet()) {
16 | sbuffer.append(entry.getValue());
17 | }
18 | String signTemp = sbuffer.toString();
19 |
20 | String sign = "";
21 | if (!"".equals(privateKey)) {
22 | sign = RSA.sign(signTemp, privateKey);
23 | }
24 | return sign;
25 | }
26 |
27 | /**
28 | * 返回的结果进行验签
29 | *
30 | * @param data
31 | * 业务数据密文
32 | * @param encrypt_key
33 | * 对ybAesKey加密后的密文
34 | * @param clientPublicKey
35 | * 客户端公钥
36 | * @param serverPrivateKey
37 | * 服务器私钥
38 | * @return 验签是否通过
39 | * @throws Exception
40 | */
41 | /*public static boolean checkDecryptAndSign(String data, String encrypt_key,
42 | String clientPublicKey, String serverPrivateKey) throws Exception {
43 |
44 | *//** 1.使用serverPrivateKey解开aesEncrypt。 *//*
45 | String AESKey = "";
46 | try {
47 | AESKey = RSA.decrypt(encrypt_key, serverPrivateKey);
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | *//** AES密钥解密失败 *//*
51 |
52 | Log.e(TAG,"checkDecryptAndSign---error:" + e + "---message:" + e.getMessage());
53 | return false;
54 | }
55 |
56 | *//** 2.用aeskey解开data。取得data明文 *//*
57 | String realData = ConvertUtils.hexStringToString(AES.decryptFromBase64(data, AESKey));
58 |
59 | TreeMap map = JSON.parseObject(realData,
60 | new TypeReference>() {});
61 |
62 | *//** 3.取得data明文sign。 *//*
63 | String sign = StringUtils.trimToEmpty(map.get("sign"));
64 |
65 | *//** 4.对map中的值进行验证 *//*
66 | StringBuffer signData = new StringBuffer();
67 | Iterator> iter = map.entrySet().iterator();
68 | while (iter.hasNext()) {
69 | Entry entry = iter.next();
70 |
71 | *//** 把sign参数隔过去 *//*
72 | if (StringUtils.equals((String) entry.getKey(), "sign")) {
73 | continue;
74 | }
75 | signData.append(entry.getValue() == null ? "" : entry.getValue());
76 | }
77 |
78 | *//** 5. result为true时表明验签通过 *//*
79 | boolean result = RSA.checkSign(signData.toString(), sign,
80 | clientPublicKey);
81 |
82 | return result;
83 | }*/
84 |
85 | /**
86 | * 生成hmac
87 | */
88 | public static String handleHmac(TreeMap map, String hmacKey) {
89 | StringBuffer sbuffer = new StringBuffer();
90 | for (Entry entry : map.entrySet()) {
91 | sbuffer.append(entry.getValue());
92 | }
93 | String hmacTemp = sbuffer.toString();
94 |
95 | String hmac = "";
96 | if (!"".equals(hmacKey)) {
97 | hmac = Digest.hmacSHASign(hmacTemp, hmacKey, Digest.ENCODE);
98 | }
99 | return hmac;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/EncryptionUtil.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | import java.security.MessageDigest;
4 |
5 | /**
6 | * Description: 加密工具类
7 | *
8 | * @author: stvelzhang
9 | * @date: 2020/7/21 15:28
10 | */
11 | public class EncryptionUtil {
12 |
13 | /**
14 | * 对字符串进行md5加密
15 | *
16 | * @param str
17 | * @return
18 | */
19 | public static String md5(String str) {
20 | try {
21 | MessageDigest md = MessageDigest.getInstance("MD5");
22 | md.update(str.getBytes());
23 | return byteToHex(md.digest());
24 | } catch (Exception e) {
25 | e.printStackTrace();
26 | }
27 | return "";
28 | }
29 |
30 | /**
31 | * 对字符串进行sha256加密
32 | *
33 | * @param str
34 | * @return
35 | */
36 | public static String sha256(String str) {
37 | try {
38 | MessageDigest md = MessageDigest.getInstance("SHA-256");
39 | md.update(str.getBytes());
40 | return byteToHex(md.digest());
41 | } catch (Exception e) {
42 | e.printStackTrace();
43 | }
44 | return "";
45 | }
46 |
47 | /**
48 | * 对字符串进行sha1加密
49 | *
50 | * @param str
51 | * @return
52 | */
53 | public static String sha1(String str) {
54 | try {
55 | MessageDigest md = MessageDigest.getInstance("SHA-1");
56 | md.update(str.getBytes());
57 | return byteToHex(md.digest());
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | return "";
62 | }
63 |
64 | /**
65 | * 字节数组转16进制字符串
66 | *
67 | * @param data
68 | * @return
69 | */
70 | public static String byteToHex(byte[] data) {
71 | final StringBuilder builder = new StringBuilder();
72 | for(byte b : data) {
73 | builder.append(String.format("%02x", b));
74 | }
75 | return builder.toString();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/RSA.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 | /*
4 | --------------------------------------------**********--------------------------------------------
5 |
6 | 该算法于1977年由美国麻省理工学院MIT(Massachusetts Institute of Technology)的Ronal Rivest,Adi Shamir和Len Adleman三位年轻教授提出,并以三人的姓氏Rivest,Shamir和Adlernan命名为RSA算法,是一个支持变长密钥的公共密钥算法,需要加密的文件快的长度也是可变的!
7 |
8 | 所谓RSA加密算法,是世界上第一个非对称加密算法,也是数论的第一个实际应用。它的算法如下:
9 |
10 | 1.找两个非常大的质数p和q(通常p和q都有155十进制位或都有512十进制位)并计算n=pq,k=(p-1)(q-1)。
11 |
12 | 2.将明文编码成整数M,保证M不小于0但是小于n。
13 |
14 | 3.任取一个整数e,保证e和k互质,而且e不小于0但是小于k。加密钥匙(称作公钥)是(e, n)。
15 |
16 | 4.找到一个整数d,使得ed除以k的余数是1(只要e和n满足上面条件,d肯定存在)。解密钥匙(称作密钥)是(d, n)。
17 |
18 | 加密过程: 加密后的编码C等于M的e次方除以n所得的余数。
19 |
20 | 解密过程: 解密后的编码N等于C的d次方除以n所得的余数。
21 |
22 | 只要e、d和n满足上面给定的条件。M等于N。
23 |
24 | --------------------------------------------**********--------------------------------------------
25 | */
26 | import android.util.Log;
27 |
28 | import java.math.BigInteger;
29 | import java.security.Key;
30 | import java.security.KeyFactory;
31 | import java.security.KeyPair;
32 | import java.security.KeyPairGenerator;
33 | import java.security.PrivateKey;
34 | import java.security.PublicKey;
35 | import java.security.SecureRandom;
36 | import java.security.Signature;
37 | import java.security.interfaces.RSAPublicKey;
38 | import java.security.spec.PKCS8EncodedKeySpec;
39 | import java.security.spec.X509EncodedKeySpec;
40 | import java.util.HashMap;
41 | import java.util.Map;
42 |
43 | import javax.crypto.Cipher;
44 |
45 |
46 | public class RSA {
47 | private static final String TAG = "revoaesrsa";
48 | /** 指定key的大小 */
49 | private static int KEYSIZE = 2048;
50 |
51 | public static final String serverPrivateKey = "MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAtYp4PvgmaWQpUGAj" +
52 | "xNAuvhZcg2g4R3NyJ74G/uWwvOad8hIl2/o9y80yemgHw9HmX283F1lrbtalaK7x" +
53 | "Uw1WCwIDAQABAkARYzrTJSdgrsQ6O4sRfbMMZ83ilCfXyBnl7pBy94LvBKobYKQi" +
54 | "Q8V9L88H3SDXpjwV1ukRk+YWVks4WHAcIcvBAiEA7cwYFpm7808Zcpyfjj1za6Xv" +
55 | "FGniDbVkNSQAS8t8vuECIQDDb/gKU+gVgrnbsbrn2qqC4Ntp01CimUDILBAPgOFO" +
56 | "awIhALn6vXwvkEeivYxd4owkk3jFtk6I4TtHeq/1ECY3Z8EBAiEAwDkBws6yR23z" +
57 | "ddUCW4bkDKQyyoxQFA0d/YPxK/58HA8CIQCDkU4pn+IUlNc/4dG3nz82rgUqVy8U" +
58 | "MQyU4NgFFtjo6g==";
59 | public static final String serverPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALWKeD74JmlkKVBgI8TQLr4WXINoOEdz" +
60 | "cie+Bv7lsLzmnfISJdv6PcvNMnpoB8PR5l9vNxdZa27WpWiu8VMNVgsCAwEAAQ==";
61 |
62 | /**
63 | * 生成密钥对
64 | */
65 | public static Map generateKeyPair() throws Exception {
66 | /** RSA算法要求有一个可信任的随机数源 */
67 | SecureRandom sr = new SecureRandom();
68 | /** 为RSA算法创建一个KeyPairGenerator对象 */
69 | KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
70 | /** 利用上面的随机数据源初始化这个KeyPairGenerator对象 */
71 | kpg.initialize(KEYSIZE, sr);
72 | /** 生成密匙对 */
73 | KeyPair kp = kpg.generateKeyPair();
74 | /** 得到公钥 */
75 | Key publicKey = kp.getPublic();
76 | byte[] publicKeyBytes = publicKey.getEncoded();
77 | String pub = new String(Base64.encodeBase64(publicKeyBytes),
78 | ConfigureEncryptAndDecrypt.CHAR_ENCODING);
79 | /** 得到私钥 */
80 | Key privateKey = kp.getPrivate();
81 | byte[] privateKeyBytes = privateKey.getEncoded();
82 | String pri = new String(Base64.encodeBase64(privateKeyBytes),
83 | ConfigureEncryptAndDecrypt.CHAR_ENCODING);
84 |
85 | Map map = new HashMap();
86 | map.put("publicKey", pub);
87 | map.put("privateKey", pri);
88 | RSAPublicKey rsp = (RSAPublicKey) kp.getPublic();
89 | BigInteger bint = rsp.getModulus();
90 | byte[] b = bint.toByteArray();
91 | byte[] deBase64Value = Base64.encodeBase64(b);
92 | String retValue = new String(deBase64Value);
93 | map.put("modulus", retValue);
94 | return map;
95 | }
96 |
97 | /**
98 | * 加密方法 source: 源数据
99 | */
100 | public static String encrypt(String source, String publicKey)
101 | throws Exception {
102 | Key key = getPublicKey(publicKey);
103 | /** 得到Cipher对象来实现对源数据的RSA加密 */
104 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.RSA_ALGORITHM);
105 | cipher.init(Cipher.ENCRYPT_MODE, key);
106 | byte[] b = source.getBytes();
107 | /** 执行加密操作 */
108 | byte[] b1 = cipher.doFinal(b);
109 | return new String(Base64.encodeBase64(b1),
110 | ConfigureEncryptAndDecrypt.CHAR_ENCODING);
111 | }
112 |
113 | /**
114 | * 解密算法 cryptograph:密文
115 | */
116 | public static String decrypt(String cryptograph, String privateKey)
117 | throws Exception {
118 | Key key = getPrivateKey(privateKey);
119 | /** 得到Cipher对象对已用公钥加密的数据进行RSA解密 */
120 | Cipher cipher = Cipher.getInstance(ConfigureEncryptAndDecrypt.RSA_ALGORITHM);
121 | cipher.init(Cipher.DECRYPT_MODE, key);
122 | byte[] b1 = Base64.decodeBase64(cryptograph.getBytes());
123 | /** 执行解密操作 */
124 | byte[] b = cipher.doFinal(b1);
125 | return new String(b);
126 | }
127 |
128 | /**
129 | * 得到公钥
130 | *
131 | * @param key
132 | * 密钥字符串(经过base64编码)
133 | * @throws Exception
134 | */
135 | public static PublicKey getPublicKey(String key) throws Exception {
136 | X509EncodedKeySpec keySpec = new X509EncodedKeySpec(
137 | Base64.decodeBase64(key.getBytes()));
138 | KeyFactory keyFactory = KeyFactory.getInstance("RSA");
139 | PublicKey publicKey = keyFactory.generatePublic(keySpec);
140 | return publicKey;
141 | }
142 |
143 | /**
144 | * 得到私钥
145 | *
146 | * @param key
147 | * 密钥字符串(经过base64编码)
148 | * @throws Exception
149 | */
150 | public static PrivateKey getPrivateKey(String key) throws Exception {
151 | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(
152 | Base64.decodeBase64(key.getBytes()));
153 | KeyFactory keyFactory = KeyFactory.getInstance("RSA");
154 | PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
155 | return privateKey;
156 | }
157 |
158 | public static String sign(String content, String privateKey) {
159 | String charset = ConfigureEncryptAndDecrypt.CHAR_ENCODING;
160 | try {
161 | PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(
162 | Base64.decodeBase64(privateKey.getBytes()));
163 | KeyFactory keyf = KeyFactory.getInstance("RSA");
164 | PrivateKey priKey = keyf.generatePrivate(priPKCS8);
165 |
166 | Signature signature = Signature.getInstance("SHA256WithRSA");
167 |
168 | signature.initSign(priKey);
169 | signature.update(content.getBytes(charset));
170 |
171 | byte[] signed = signature.sign();
172 |
173 | return new String(Base64.encodeBase64(signed));
174 | } catch (Exception e) {
175 |
176 | }
177 |
178 | return null;
179 | }
180 |
181 | public static boolean checkSign(String content, String sign, String publicKey)
182 | {
183 | try
184 | {
185 | KeyFactory keyFactory = KeyFactory.getInstance("RSA");
186 | byte[] encodedKey = Base64.decode2(publicKey);
187 | PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
188 |
189 |
190 | Signature signature = Signature
191 | .getInstance("SHA256WithRSA");
192 |
193 | signature.initVerify(pubKey);
194 | signature.update( content.getBytes("utf-8") );
195 |
196 | boolean bverify = signature.verify( Base64.decode2(sign) );
197 | return bverify;
198 |
199 | }
200 | catch (Exception e)
201 | {
202 | Log.e(TAG,"checkSign---error:" + e.getMessage());
203 | }
204 |
205 | return false;
206 | }
207 |
208 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/revo/aesrsa/resrsa/SecureRandomUtil.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa.resrsa;
2 |
3 |
4 | import java.security.SecureRandom;
5 |
6 | public class SecureRandomUtil {
7 |
8 | public static SecureRandom random = new SecureRandom();
9 |
10 | public static String getRandom(int length) {
11 | StringBuilder ret = new StringBuilder();
12 | for (int i = 0; i < length; i++) {
13 | boolean isChar = (random.nextInt(2) % 2 == 0);// 输出字母还是数字
14 | if (isChar) { // 字符串
15 | int choice = random.nextInt(2) % 2 == 0 ? 65 : 97; // 取得大写字母还是小写字母
16 | ret.append((char) (choice + random.nextInt(26)));
17 | } else { // 数字
18 | ret.append(Integer.toString(random.nextInt(10)));
19 | }
20 | }
21 | return ret.toString();
22 | }
23 |
24 | public static String getRandomNum(int length) {
25 | StringBuilder ret = new StringBuilder();
26 | for (int i = 0; i < length; i++) {
27 | ret.append(Integer.toString(random.nextInt(10)));
28 | }
29 | return ret.toString();
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 | LOCAL_LDFLAGS := -Wl,--build-id
5 | LOCAL_MODULE := JniUtil
6 |
7 | LOCAL_SRC_FILES := \
8 | aes256.c \
9 | base64.c \
10 | JniUtil.c \
11 | JniLib.cpp
12 |
13 | MODULE_CPPFLAGS:= -std=c++11
14 | LOCAL_LDLIBS += -llog
15 |
16 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
17 | LOCAL_PROGUARD_ENABLED:= disabled
18 | include $(BUILD_SHARED_LIBRARY)
--------------------------------------------------------------------------------
/app/src/main/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_MODULES := JniUtil
2 | APP_ABI := all
--------------------------------------------------------------------------------
/app/src/main/jni/JniLib.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Administrator on 2020/8/3.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "base64.h"
12 | #include
13 |
14 |
15 | #define LOG "fuckDemo-jni" // 这个是自定义的LOG的标识
16 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG,__VA_ARGS__) // 定义LOGD类型
17 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG,__VA_ARGS__) // 定义LOGI类型
18 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG,__VA_ARGS__) // 定义LOGW类型
19 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG,__VA_ARGS__) // 定义LOGE类型
20 | #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG,__VA_ARGS__) // 定义LOGF类型
21 |
22 |
23 | const char keyValue[] = {
24 | 21, 25, 21, 45, 25, 98, 55, 45, 10, 35, 45, 35,
25 | 26, 5, 25, 65, 78, 99, 85, 45, 5, 10, 0, 11,
26 | 35, 48, 98, 65, 32, 14, 67, 25, 36, 56, 45, 5,
27 | 12, 15, 35, 15, 25, 14, 62, 25, 33, 45, 55, 12, 8
28 | };
29 |
30 | const char iv[] = { //16 bit
31 | 33, 32, 25, 25, 35, 27, 55, 12, 15,32,
32 | 23, 45, 26, 32, 5,16
33 | };
34 |
35 | const uint8_t AesKey[32] = {
36 | 0x77,0x6f,0x6a,0x69,
37 | 0x75,0x62,0x75,0x67,
38 | 0x61,0x6f,0x73,0x75,
39 | 0x6e,0x69,0x6d,0x65,
40 | 0x6e,0x67,0x6c,0x61,
41 | 0x6c,0x69,0x73,0x61,
42 | 0x64,0x65,0x79,0x61,
43 | 0x6e,0x6c,0x65,0x69
44 | };
45 |
46 | const uint8_t AesIv[16] = {
47 | 0x6e,0x67,0x6c,0x61,
48 | 0x6c,0x69,0x73,0x61,
49 | 0x64,0x65,0x79,0x61,
50 | 0x6e,0x6c,0x65,0x69
51 | };
52 |
53 |
54 |
55 |
56 |
57 | #define LEN 512
58 | /*
59 | * Class: com_revo_aesrsa_JniUtil
60 | * Method: getString
61 | * Signature: ()Ljava/lang/String;
62 | */
63 | extern "C" {
64 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getString
65 | (JNIEnv *env, jobject obj){
66 | const char keyvalue[8] = {'s','t','v','e','l','z','s','x'};
67 | return env->NewStringUTF(keyvalue);
68 | // return env->NewStringUTF("hello,TEE-CA--stvelzhang from C++");
69 | }
70 | }
71 |
72 |
73 | /*
74 | * Class: com_revo_aesrsa_JniUtil
75 | * Method: add
76 | * Signature: (II)I
77 | */
78 | extern "C" {
79 | JNIEXPORT jint JNICALL Java_com_revo_aesrsa_JniUtil_add
80 | (JNIEnv *env, jobject obj, jint k, jint j){
81 | int i;
82 |
83 | const unsigned char master_key[16] = {
84 | '1', '2', '3', '4', '5', '6', '7', '8',
85 | '9', '0', 'a', 'b', 'c', 'd', 'e', 'f',
86 | };
87 | const unsigned char text[16] = {
88 | '1', '2', '3', '4', '5', '6', '7', '8',
89 | '9', '0', 'a', 'b', 'c', 'd', 'e', 'f',
90 | };
91 |
92 | const unsigned char iv[16] = {
93 | '9', '0', 'a', 'b', 'c', 'd', 'e', 'f',
94 | '1', '2', '3', '4', '5', '6', '7', '8',
95 | };
96 |
97 | unsigned char ivc[16];
98 |
99 | unsigned char encrypted[16], decrypted[16];
100 | memset(encrypted, 0, 16*sizeof(char));
101 | memset(decrypted, 0, 16*sizeof(char));
102 |
103 | return k + j;
104 | }
105 | }
106 |
107 |
108 |
109 | /*
110 | * Class: com_revo_aesrsa_JniUtil
111 | * Method: getKeyValue
112 | * Signature: ()Ljava/lang/String;
113 | */
114 | extern "C" {
115 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getKeyValue
116 | (JNIEnv *env, jobject obj){
117 |
118 | jbyteArray KeyArray = env->NewByteArray(sizeof(AesKey));
119 | jbyte *bytes = env->GetByteArrayElements(KeyArray, 0);
120 |
121 | int i;
122 |
123 | for (i = 0; i < sizeof(AesKey); i++){
124 |
125 |
126 | //__android_log_print(ANDROID_LOG_ERROR,LOG,"AesIv的是%d",AesKey[i]);
127 | bytes[i] = (jbyte) (AesKey[i]);
128 | //__android_log_print(ANDROID_LOG_ERROR,LOG,"bytes[i] %d",bytes[i]);
129 | }
130 |
131 | env->SetByteArrayRegion(KeyArray, 0, sizeof(iv), bytes);
132 | env->ReleaseByteArrayElements(KeyArray,bytes,0);
133 |
134 | jclass strClass = env->FindClass("java/lang/String");
135 | jmethodID ctorID = env->GetMethodID(strClass, "", "([BLjava/lang/String;)V");
136 |
137 | jstring encoding = env->NewStringUTF("utf-8");
138 |
139 | return (jstring)env->NewObject(strClass, ctorID, KeyArray, encoding);
140 |
141 | }
142 | }
143 |
144 |
145 | /*
146 | * Class: com_revo_aesrsa_JniUtil
147 | * Method: getIv
148 | * Signature: ()Ljava/lang/String;
149 | */
150 | extern "C" {
151 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getIv
152 | (JNIEnv *env, jobject obj){
153 |
154 |
155 | jbyteArray ivArray = env->NewByteArray(sizeof(AesIv));
156 | jbyte *bytes = env->GetByteArrayElements(ivArray, 0);
157 |
158 | int i;
159 |
160 | for (i = 0; i < sizeof(AesIv); i++){
161 |
162 |
163 | // __android_log_print(ANDROID_LOG_ERROR,LOG,"AesIv的是%d",AesIv[i]);
164 | bytes[i] = (jbyte) (AesIv[i]);
165 | // __android_log_print(ANDROID_LOG_ERROR,LOG,"bytes[i] %d",bytes[i]);
166 | }
167 |
168 | env->SetByteArrayRegion(ivArray, 0, sizeof(iv), bytes);
169 | env->ReleaseByteArrayElements(ivArray,bytes,0);
170 |
171 | jclass strClass = env->FindClass("java/lang/String");
172 | jmethodID ctorID = env->GetMethodID(strClass, "", "([BLjava/lang/String;)V");
173 |
174 | jstring encoding = env->NewStringUTF("utf-8");
175 |
176 | return (jstring)env->NewObject(strClass, ctorID, ivArray, encoding);
177 | }
178 |
179 | }
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/app/src/main/jni/JniUtil.c:
--------------------------------------------------------------------------------
1 | //
2 | // Created by xing.chang on 2018/10/24.
3 | //
4 |
5 | #include
6 | #include "base64.h"
7 | #include
8 | #include
9 | #include
10 |
11 |
12 | #define TAG "myDemo-jni" // 这个是自定义的LOG的标识
13 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__) // 定义LOGD类型
14 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__) // 定义LOGI类型
15 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,TAG ,__VA_ARGS__) // 定义LOGW类型
16 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,TAG ,__VA_ARGS__) // 定义LOGE类型
17 | #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,TAG ,__VA_ARGS__) // 定义LOGF类型
18 |
19 | jstring charToJstring(JNIEnv* envPtr, char *src) {
20 | JNIEnv env = *envPtr;
21 |
22 | jsize len = strlen(src);
23 | jclass clsstring = env->FindClass(envPtr, "java/lang/String");
24 | jstring strencode = env->NewStringUTF(envPtr, "UTF-8");
25 | jmethodID mid = env->GetMethodID(envPtr, clsstring, "", "([BLjava/lang/String;)V");
26 | jbyteArray barr = env->NewByteArray(envPtr, len);
27 | env->SetByteArrayRegion(envPtr, barr, 0, len, (jbyte*) src);
28 |
29 | return (jstring) env->NewObject(envPtr, clsstring, mid, barr, strencode);
30 | }
31 |
32 | jstring encrypt(JNIEnv* envPtr, jstring mingwen) {
33 | JNIEnv env = *envPtr;
34 |
35 | //wojiubugaosunimenglalisadeyanlei 秘钥
36 | unsigned char key[32] = {0x77,0x6f,0x6a,0x69,
37 | 0x75,0x62,0x75,0x67,
38 | 0x61,0x6f,0x73,0x75,
39 | 0x6e,0x69,0x6d,0x65,
40 | 0x6e,0x67,0x6c,0x61,
41 | 0x6c,0x69,0x73,0x61,
42 | 0x64,0x65,0x79,0x61,
43 | 0x6e,0x6c,0x65,0x69};
44 |
45 | //****************************************开始加密******************************************************
46 | //1.初始化数据
47 | //初始化向量 nglalisadeyanlei
48 | uint8_t iv[16] = { 0x6e,0x67,0x6c,0x61,
49 | 0x6c,0x69,0x73,0x61,
50 | 0x64,0x65,0x79,0x61,
51 | 0x6e,0x6c,0x65,0x69 };
52 |
53 | //初始化加密参数
54 | aes256_context ctx;
55 | aes256_init(&ctx, key);
56 |
57 | //2.将jstring转为char
58 | const char *mwChar = env->GetStringUTFChars(envPtr, mingwen, JNI_FALSE);
59 |
60 | //3.分组填充加密
61 | int i;
62 | int mwSize = strlen(mwChar);
63 | int remainder = mwSize % 16;
64 | jstring entryptString;
65 | if (mwSize < 16) { //小于16字节,填充16字节,后面填充几个几 比方说10个字节 就要补齐6个6 11个字节就补齐5个5
66 | uint8_t input[16];
67 | for (i = 0; i < 16; i++) {
68 | if (i < mwSize) {
69 | input[i] = (unsigned char) mwChar[i];
70 | } else {
71 | input[i] = (unsigned char) (16 - mwSize);
72 | }
73 | }
74 | //加密
75 | uint8_t output[16];
76 | aes256_encrypt_cbc(&ctx, input, iv, output);
77 | //base64加密后然后jstring格式输出
78 | char *enc = base64_encode((const char *) output, sizeof(output));
79 | entryptString = charToJstring(envPtr, enc);
80 |
81 | free(enc);
82 | } else { //如果是16的倍数,填充16字节,后面填充0x10
83 | int group = mwSize / 16;
84 | int size = 16 * (group + 1);
85 | uint8_t input[size];
86 | for (i = 0; i < size; i++) {
87 | if (i < mwSize) {
88 | input[i] = (unsigned char) mwChar[i];
89 | } else {
90 | if (remainder == 0) {
91 | input[i] = 0x10;
92 | } else { //如果不足16位 少多少位就补几个几 如:少4为就补4个4 以此类推
93 | int dif = size - mwSize;
94 | input[i] = (unsigned char) dif;
95 | }
96 | }
97 | }
98 | //加密
99 | uint8_t output[size];
100 | aes256_encrypt_cbc(&ctx, input, iv, output);
101 | //base64加密后然后jstring格式输出
102 | //LOGD("encrypt output size=%d",size);
103 | char *enc = base64_encode((const char *) output, sizeof(output));
104 | // LOGD("encrypt enc=%s",enc);
105 | entryptString = charToJstring(envPtr, enc);
106 |
107 | free(enc);
108 | }
109 |
110 | //释放mwChar
111 | env->ReleaseStringUTFChars(envPtr, mingwen, mwChar);
112 |
113 | return entryptString;
114 | }
115 |
116 |
117 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_encrypt
118 | (JNIEnv *env, jobject instance, jstring jstr){
119 | if (jstr == NULL) {
120 | return NULL;
121 | }
122 | return encrypt(env,jstr);
123 | }
124 |
125 | jstring decrypt(JNIEnv* env, jstring miwen) {
126 | jstring result;
127 |
128 |
129 | //wojiubugaosunimenglalisadeyanlei 秘钥
130 | unsigned char key[32] = {0x77,0x6f,0x6a,0x69,
131 | 0x75,0x62,0x75,0x67,
132 | 0x61,0x6f,0x73,0x75,
133 | 0x6e,0x69,0x6d,0x65,
134 | 0x6e,0x67,0x6c,0x61,
135 | 0x6c,0x69,0x73,0x61,
136 | 0x64,0x65,0x79,0x61,
137 | 0x6e,0x6c,0x65,0x69};
138 |
139 | //****************************************开始解密******************************************************
140 | //1.初始化数据
141 | //初始化向量 nglalisadeyanlei
142 | uint8_t iv[16] = { 0x6e,0x67,0x6c,0x61,
143 | 0x6c,0x69,0x73,0x61,
144 | 0x64,0x65,0x79,0x61,
145 | 0x6e,0x6c,0x65,0x69 };
146 | aes256_context ctx;
147 | aes256_init(&ctx, key);
148 |
149 | //2.将jstring转为char
150 | const char *mwChar = (*env)->GetStringUTFChars(env, miwen, JNI_FALSE);
151 | char *enc = base64_decode(mwChar, strlen(mwChar));
152 | uint8_t output[4096];
153 | aes256_decrypt_cbc(&ctx, (unsigned char *) enc, iv, output);
154 | int size = strlen((const char *) output);
155 | LOGD("output size=%d",size);
156 | int i;
157 | for(i=0;i=1&&output[i]<=16){
160 | output[i] = 0;
161 | }
162 | }
163 | result = charToJstring(env, (char *) output);
164 | //LOGD("result=%s",(char *) output);
165 | free(enc);
166 | //释放mwChar
167 | (*env)->ReleaseStringUTFChars(env, miwen, mwChar);
168 | aes256_done(&ctx);
169 | return result;
170 | }
171 |
172 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_decrypt
173 | (JNIEnv *env, jobject instance, jstring jstr){
174 | if (jstr == NULL) {
175 | return NULL;
176 | }
177 | return decrypt(env,jstr);
178 | }
179 |
180 |
--------------------------------------------------------------------------------
/app/src/main/jni/aes256.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Byte-oriented AES-256 implementation.
3 | *
4 | * CBC PKCS5Padding with iv
5 |
6 | * All lookup tables replaced with 'on the fly' calculations.
7 | *
8 | * Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
9 | * Other contributors: Hal Finney
10 | *
11 | * Permission to use, copy, modify, and distribute this software for any
12 | * purpose with or without fee is hereby granted, provided that the above
13 | * copyright notice and this permission notice appear in all copies.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 | * coded by longdw 2015.5.21
23 | * http://www.longdw.com
24 | */
25 | #include "aes256.h"
26 |
27 | #define F(x) (((x)<<1) ^ ((((x)>>7) & 1) * 0x1b))
28 | #define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0))
29 |
30 | // #define BACK_TO_TABLES
31 | #ifdef BACK_TO_TABLES
32 |
33 | const uint8_t sbox[256] = {
34 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
35 | 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
36 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
37 | 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
38 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
39 | 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
40 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
41 | 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
42 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
43 | 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
44 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
45 | 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
46 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
47 | 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
48 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
49 | 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
50 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
51 | 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
52 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
53 | 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
54 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
55 | 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
56 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
57 | 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
58 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
59 | 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
60 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
61 | 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
62 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
63 | 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
64 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
65 | 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
66 | };
67 | const uint8_t sboxinv[256] = {
68 | 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38,
69 | 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
70 | 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
71 | 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
72 | 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d,
73 | 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
74 | 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2,
75 | 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
76 | 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
77 | 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
78 | 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda,
79 | 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
80 | 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a,
81 | 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
82 | 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
83 | 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
84 | 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea,
85 | 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
86 | 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85,
87 | 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
88 | 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
89 | 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
90 | 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20,
91 | 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
92 | 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31,
93 | 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
94 | 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
95 | 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
96 | 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0,
97 | 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
98 | 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26,
99 | 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
100 | };
101 |
102 | #define rj_sbox(x) sbox[(x)]
103 | #define rj_sbox_inv(x) sboxinv[(x)]
104 |
105 | #else /* tableless subroutines */
106 |
107 | /* -------------------------------------------------------------------------- */
108 | uint8_t gf_alog(uint8_t x) // calculate anti-logarithm gen 3
109 | {
110 | uint8_t atb = 1, z;
111 |
112 | while (x--)
113 | {
114 | z = atb;
115 | atb <<= 1;
116 | if (z & 0x80)
117 | atb^= 0x1b; atb ^= z;
118 | }
119 |
120 | return atb;
121 | } /* gf_alog */
122 |
123 | /* -------------------------------------------------------------------------- */
124 | uint8_t gf_log(uint8_t x) // calculate logarithm gen 3
125 | {
126 | uint8_t atb = 1, i = 0, z;
127 |
128 | do {
129 | if (atb == x) break;
130 | z = atb; atb <<= 1;
131 | if (z & 0x80)
132 | atb^= 0x1b; atb ^= z;
133 | } while (++i > 0);
134 |
135 | return i;
136 | } /* gf_log */
137 |
138 |
139 | /* -------------------------------------------------------------------------- */
140 | uint8_t gf_mulinv(uint8_t x) // calculate multiplicative inverse
141 | {
142 | return (x) ? gf_alog(255 - gf_log(x)) : 0;
143 | } /* gf_mulinv */
144 |
145 | /* -------------------------------------------------------------------------- */
146 | uint8_t rj_sbox(uint8_t x)
147 | {
148 | uint8_t y, sb;
149 |
150 | sb = y = gf_mulinv(x);
151 | y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y;
152 | y = (y<<1)|(y>>7); sb ^= y; y = (y<<1)|(y>>7); sb ^= y;
153 |
154 | return (sb ^ 0x63);
155 | } /* rj_sbox */
156 |
157 | /* -------------------------------------------------------------------------- */
158 | uint8_t rj_sbox_inv(uint8_t x)
159 | {
160 | uint8_t y, sb;
161 |
162 | y = x ^ 0x63;
163 | sb = y = (y<<1)|(y>>7);
164 | y = (y<<2)|(y>>6); sb ^= y; y = (y<<3)|(y>>5); sb ^= y;
165 |
166 | return gf_mulinv(sb);
167 | } /* rj_sbox_inv */
168 |
169 | #endif
170 |
171 | /* -------------------------------------------------------------------------- */
172 | uint8_t rj_xtime(uint8_t x)
173 | {
174 | return (x & 0x80) ? ((x << 1) ^ 0x1b) : (x << 1);
175 | } /* rj_xtime */
176 |
177 | /* -------------------------------------------------------------------------- */
178 | void aes_subBytes(uint8_t *buf)
179 | {
180 | register uint8_t i = 16;
181 | //register uint8_t i = 32;
182 |
183 | while (i--) buf[i] = rj_sbox(buf[i]);
184 | } /* aes_subBytes */
185 |
186 | /* -------------------------------------------------------------------------- */
187 | void aes_subBytes_inv(uint8_t *buf)
188 | {
189 | register uint8_t i = 16;
190 | //register uint8_t i = 32;
191 |
192 | while (i--) buf[i] = rj_sbox_inv(buf[i]);
193 | } /* aes_subBytes_inv */
194 |
195 | /* -------------------------------------------------------------------------- */
196 | void aes_addRoundKey(uint8_t *buf, uint8_t *key)
197 | {
198 | register uint8_t i = 16;
199 | //register uint8_t i = 32;
200 | while (i--) buf[i] ^= key[i];
201 | } /* aes_addRoundKey */
202 |
203 | /* -------------------------------------------------------------------------- */
204 | void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk)
205 | {
206 | register uint8_t i = 16;
207 | //register uint8_t i = 32;
208 |
209 | while (i--) buf[i] ^= (cpk[i] = key[i]), cpk[16+i] = key[16 + i];
210 | } /* aes_addRoundKey_cpy */
211 |
212 |
213 | /* -------------------------------------------------------------------------- */
214 | void aes_shiftRows(uint8_t *buf)
215 | {
216 | register uint8_t i, j; /* to make it potentially parallelable :) */
217 |
218 | i = buf[1]; buf[1] = buf[5]; buf[5] = buf[9]; buf[9] = buf[13]; buf[13] = i;
219 | i = buf[10]; buf[10] = buf[2]; buf[2] = i;
220 | j = buf[3]; buf[3] = buf[15]; buf[15] = buf[11]; buf[11] = buf[7]; buf[7] = j;
221 | j = buf[14]; buf[14] = buf[6]; buf[6] = j;
222 |
223 | } /* aes_shiftRows */
224 |
225 | /* -------------------------------------------------------------------------- */
226 | void aes_shiftRows_inv(uint8_t *buf)
227 | {
228 | register uint8_t i, j; /* same as above :) */
229 |
230 | i = buf[1]; buf[1] = buf[13]; buf[13] = buf[9]; buf[9] = buf[5]; buf[5] = i;
231 | i = buf[2]; buf[2] = buf[10]; buf[10] = i;
232 | j = buf[3]; buf[3] = buf[7]; buf[7] = buf[11]; buf[11] = buf[15]; buf[15] = j;
233 | j = buf[6]; buf[6] = buf[14]; buf[14] = j;
234 |
235 | } /* aes_shiftRows_inv */
236 |
237 | /* -------------------------------------------------------------------------- */
238 | void aes_mixColumns(uint8_t *buf)
239 | {
240 | register uint8_t i, a, b, c, d, e;
241 |
242 | for (i = 0; i < 16; i += 4)
243 | {
244 | a = buf[i]; b = buf[i + 1]; c = buf[i + 2]; d = buf[i + 3];
245 | e = a ^ b ^ c ^ d;
246 | buf[i] ^= e ^ rj_xtime(a^b); buf[i+1] ^= e ^ rj_xtime(b^c);
247 | buf[i+2] ^= e ^ rj_xtime(c^d); buf[i+3] ^= e ^ rj_xtime(d^a);
248 | }
249 | } /* aes_mixColumns */
250 |
251 | /* -------------------------------------------------------------------------- */
252 | void aes_mixColumns_inv(uint8_t *buf)
253 | {
254 | register uint8_t i, a, b, c, d, e, x, y, z;
255 |
256 | for (i = 0; i < 16; i += 4)
257 | {
258 | a = buf[i]; b = buf[i + 1]; c = buf[i + 2]; d = buf[i + 3];
259 | e = a ^ b ^ c ^ d;
260 | z = rj_xtime(e);
261 | x = e ^ rj_xtime(rj_xtime(z^a^c)); y = e ^ rj_xtime(rj_xtime(z^b^d));
262 | buf[i] ^= x ^ rj_xtime(a^b); buf[i+1] ^= y ^ rj_xtime(b^c);
263 | buf[i+2] ^= x ^ rj_xtime(c^d); buf[i+3] ^= y ^ rj_xtime(d^a);
264 | }
265 | } /* aes_mixColumns_inv */
266 |
267 | /* -------------------------------------------------------------------------- */
268 | void aes_expandEncKey(uint8_t *k, uint8_t *rc)
269 | {
270 | register uint8_t i;
271 |
272 | k[0] ^= rj_sbox(k[29]) ^ (*rc);
273 | k[1] ^= rj_sbox(k[30]);
274 | k[2] ^= rj_sbox(k[31]);
275 | k[3] ^= rj_sbox(k[28]);
276 | *rc = F( *rc);
277 |
278 | for(i = 4; i < 16; i += 4) k[i] ^= k[i-4], k[i+1] ^= k[i-3],
279 | k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
280 | k[16] ^= rj_sbox(k[12]);
281 | k[17] ^= rj_sbox(k[13]);
282 | k[18] ^= rj_sbox(k[14]);
283 | k[19] ^= rj_sbox(k[15]);
284 |
285 | for(i = 20; i < 32; i += 4) k[i] ^= k[i-4], k[i+1] ^= k[i-3],
286 | k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
287 |
288 | } /* aes_expandEncKey */
289 |
290 | /* -------------------------------------------------------------------------- */
291 | void aes_expandDecKey(uint8_t *k, uint8_t *rc)
292 | {
293 | uint8_t i;
294 |
295 | for(i = 28; i > 16; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3],
296 | k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
297 |
298 | k[16] ^= rj_sbox(k[12]);
299 | k[17] ^= rj_sbox(k[13]);
300 | k[18] ^= rj_sbox(k[14]);
301 | k[19] ^= rj_sbox(k[15]);
302 |
303 | for(i = 12; i > 0; i -= 4) k[i+0] ^= k[i-4], k[i+1] ^= k[i-3],
304 | k[i+2] ^= k[i-2], k[i+3] ^= k[i-1];
305 |
306 | *rc = FD(*rc);
307 | k[0] ^= rj_sbox(k[29]) ^ (*rc);
308 | k[1] ^= rj_sbox(k[30]);
309 | k[2] ^= rj_sbox(k[31]);
310 | k[3] ^= rj_sbox(k[28]);
311 | } /* aes_expandDecKey */
312 |
313 |
314 | /* -------------------------------------------------------------------------- */
315 | void aes256_init(aes256_context *ctx, uint8_t *k)
316 | {
317 | uint8_t rcon = 1;
318 | register uint8_t i;
319 |
320 | for (i = 0; i < sizeof(ctx->key); i++) ctx->enckey[i] = ctx->deckey[i] = k[i];
321 | for (i = 8;--i;) aes_expandEncKey(ctx->deckey, &rcon);
322 | } /* aes256_init */
323 |
324 | /* -------------------------------------------------------------------------- */
325 | void aes256_done(aes256_context *ctx)
326 | {
327 | register uint8_t i;
328 |
329 | for (i = 0; i < sizeof(ctx->key); i++)
330 | ctx->key[i] = ctx->enckey[i] = ctx->deckey[i] = 0;
331 | } /* aes256_done */
332 |
333 | /* -------------------------------------------------------------------------- */
334 | void aes256_encrypt(aes256_context *ctx, uint8_t *buf)
335 | {
336 | uint8_t i, rcon;
337 |
338 | aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
339 | for(i = 1, rcon = 1; i < 14; ++i)
340 | {
341 | aes_subBytes(buf);
342 | aes_shiftRows(buf);
343 | aes_mixColumns(buf);
344 | if( i & 1 ) aes_addRoundKey( buf, &ctx->key[16]);
345 | else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
346 | }
347 | aes_subBytes(buf);
348 | aes_shiftRows(buf);
349 | aes_expandEncKey(ctx->key, &rcon);
350 | aes_addRoundKey(buf, ctx->key);
351 | } /* aes256_encrypt */
352 |
353 | void aes_cbc(uint8_t *buf, uint8_t *iv)
354 | {
355 | register uint8_t i = 16;
356 | //register uint8_t i = 32;
357 | while (i--) buf[i] ^= iv[i];
358 | }/*aes_cbc*/
359 |
360 |
361 | /* -------------------------------------------------------------------------- */
362 | void aes256_decrypt(aes256_context *ctx,uint8_t *iv, uint8_t *buf)
363 | {
364 | uint8_t i, rcon;
365 |
366 | aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
367 | aes_shiftRows_inv(buf);
368 | aes_subBytes_inv(buf);
369 |
370 | for (i = 14, rcon = 0x80; --i;)
371 | {
372 | if( ( i & 1 ) )
373 | {
374 | aes_expandDecKey(ctx->key, &rcon);
375 | aes_addRoundKey(buf, &ctx->key[16]);
376 | }
377 | else aes_addRoundKey(buf, ctx->key);
378 | aes_mixColumns_inv(buf);
379 | aes_shiftRows_inv(buf);
380 | aes_subBytes_inv(buf);
381 | }
382 | aes_addRoundKey(buf, ctx->key);
383 | aes_cbc(buf,iv);
384 | } /* aes256_decrypt */
385 |
386 |
387 |
388 | void aes256_encrypt_cbc(aes256_context *ctx, uint8_t *in, uint8_t *iv, uint8_t *out)
389 | {
390 | uint8_t i, j, rcon;
391 | uint8_t buf[16],iv_change[16];
392 | int size = strlen(in) / 16;
393 |
394 | for(j = 0; j < size; j++ )
395 | {
396 | memcpy(buf, in + j * 16, 16 );
397 | if(j == 0)
398 | {
399 | aes_cbc(buf,iv);
400 | aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
401 | for(i = 1, rcon = 1; i < 14; ++i)
402 | {
403 | aes_subBytes(buf);
404 | aes_shiftRows(buf);
405 | aes_mixColumns(buf);
406 | if( i & 1 ) aes_addRoundKey(buf, &ctx->key[16]);
407 | else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
408 | }
409 | aes_subBytes(buf);
410 | aes_shiftRows(buf);
411 | aes_expandEncKey(ctx->key, &rcon);
412 | aes_addRoundKey(buf, ctx->key);
413 |
414 | memcpy(out + j * 16, buf, 16);
415 | memcpy(iv_change,buf,16);
416 | }
417 | else
418 | {
419 | aes_cbc(buf,iv_change);
420 | aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key);
421 | for(i = 1, rcon = 1; i < 14; ++i)
422 | {
423 | aes_subBytes(buf);
424 | aes_shiftRows(buf);
425 | aes_mixColumns(buf);
426 | if( i & 1 ) aes_addRoundKey(buf, &ctx->key[16]);
427 | else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key);
428 | }
429 | aes_subBytes(buf);
430 | aes_shiftRows(buf);
431 | aes_expandEncKey(ctx->key, &rcon);
432 | aes_addRoundKey(buf, ctx->key);
433 |
434 | memcpy(out + j * 16, buf, 16);
435 | memcpy(iv_change,buf,16);
436 | }
437 | }
438 | }/*aes256_encrypt_cbc*/
439 |
440 | void aes256_decrypt_cbc(aes256_context *ctx, uint8_t *in, uint8_t *iv, uint8_t *out)
441 | {
442 | uint8_t i, j, rcon;
443 | uint8_t buf[16], iv_change_1[16], iv_change_2[16];
444 |
445 | for(j = 0; j < 240; j++ )
446 | {
447 | memcpy(buf, in + j * 16, 16 );
448 | if(j == 0)
449 | {
450 | memcpy(iv_change_1,buf,16);
451 | aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
452 | aes_shiftRows_inv(buf);
453 | aes_subBytes_inv(buf);
454 |
455 | for (i = 14, rcon = 0x80; --i;)
456 | {
457 | if( ( i & 1 ) )
458 | {
459 | aes_expandDecKey(ctx->key, &rcon);
460 | aes_addRoundKey(buf, &ctx->key[16]);
461 | }
462 | else aes_addRoundKey(buf, ctx->key);
463 | aes_mixColumns_inv(buf);
464 | aes_shiftRows_inv(buf);
465 | aes_subBytes_inv(buf);
466 | }
467 | aes_addRoundKey(buf, ctx->key);
468 | aes_cbc(buf,iv);
469 |
470 | memcpy(out + j * 16, buf, 16);
471 | memcpy(iv_change_2,iv_change_1,16);
472 | }
473 | else
474 | {
475 | memcpy(iv_change_1,buf,16);
476 | aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key);
477 | aes_shiftRows_inv(buf);
478 | aes_subBytes_inv(buf);
479 |
480 | for (i = 14, rcon = 0x80; --i;)
481 | {
482 | if( ( i & 1 ) )
483 | {
484 | aes_expandDecKey(ctx->key, &rcon);
485 | aes_addRoundKey(buf, &ctx->key[16]);
486 | }
487 | else aes_addRoundKey(buf, ctx->key);
488 | aes_mixColumns_inv(buf);
489 | aes_shiftRows_inv(buf);
490 | aes_subBytes_inv(buf);
491 | }
492 | aes_addRoundKey(buf, ctx->key);
493 | aes_cbc(buf,iv_change_2);
494 |
495 | memcpy(out + j * 16, buf, 16);
496 | memcpy(iv_change_2,iv_change_1,16);
497 | }
498 | }
499 |
500 | }/*aes256_decrypt_cbc*/
501 |
--------------------------------------------------------------------------------
/app/src/main/jni/aes256.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Byte-oriented AES-256 implementation.
3 | * All lookup tables replaced with 'on the fly' calculations.
4 | *
5 | * Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com
6 | * Other contributors: Hal Finney
7 | *
8 | * Permission to use, copy, modify, and distribute this software for any
9 | * purpose with or without fee is hereby granted, provided that the above
10 | * copyright notice and this permission notice appear in all copies.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 | * coded by longdw 2015.5.21
20 | * http://www.longdw.com
21 | */
22 |
23 |
24 | #ifndef _AES256_H_
25 | #define _AES256_H_
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #ifndef uint8_t
34 | #define uint8_t unsigned char
35 | #endif
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | typedef struct {
42 | uint8_t key[32];
43 | uint8_t enckey[32];
44 | uint8_t deckey[32];
45 | } aes256_context;
46 |
47 |
48 | void aes256_init(aes256_context *, uint8_t * /* key */);
49 | void aes256_done(aes256_context *);
50 | void aes256_encrypt(aes256_context *, uint8_t * /* plaintext */);
51 | void aes256_decrypt(aes256_context *, uint8_t * ,uint8_t */* cipertext */);
52 | void aes256_encrypt_cbc(aes256_context *, uint8_t *, uint8_t *, uint8_t *);
53 | void aes256_decrypt_cbc(aes256_context *, uint8_t *, uint8_t *, uint8_t *);
54 | double GetTime();
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 |
60 | #define DUMP(s, i, buf, sz) {printf(s); \
61 | for (i = 0; i < (sz);i++) \
62 | printf("%02x ", buf[i]); \
63 | printf("\n");}
64 |
65 |
66 | #endif
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/jni/base64.c:
--------------------------------------------------------------------------------
1 | #include "base64.h"
2 |
3 | #include
4 | #include
5 |
6 | /* */
7 | char *base64_encode(const char* data, int data_len)
8 | {
9 | //int data_len = strlen(data);
10 | int prepare = 0;
11 | int ret_len;
12 | int temp = 0;
13 | char *ret = NULL;
14 | char *f = NULL;
15 | int tmp = 0;
16 | char changed[4];
17 | int i = 0;
18 | ret_len = data_len / 3;
19 | temp = data_len % 3;
20 | if (temp > 0)
21 | {
22 | ret_len += 1;
23 | }
24 | ret_len = ret_len*4 + 1;
25 | ret = (char *)malloc(ret_len);
26 |
27 | if ( ret == NULL)
28 | {
29 | printf("No enough memory.\n");
30 | exit(0);
31 | }
32 | memset(ret, 0, ret_len);
33 | f = ret;
34 | while (tmp < data_len)
35 | {
36 | temp = 0;
37 | prepare = 0;
38 | memset(changed, '\0', 4);
39 | while (temp < 3)
40 | {
41 | //printf("tmp = %d\n", tmp);
42 | if (tmp >= data_len)
43 | {
44 | break;
45 | }
46 | prepare = ((prepare << 8) | (data[tmp] & 0xFF));
47 | tmp++;
48 | temp++;
49 | }
50 | prepare = (prepare<<((3-temp)*8));
51 | //printf("before for : temp = %d, prepare = %d\n", temp, prepare);
52 | for (i = 0; i < 4 ;i++ )
53 | {
54 | if (temp < i)
55 | {
56 | changed[i] = 0x40;
57 | }
58 | else
59 | {
60 | changed[i] = (prepare>>((3-i)*6)) & 0x3F;
61 | }
62 | *f = base[changed[i]];
63 | //printf("%.2X", changed[i]);
64 | f++;
65 | }
66 | }
67 | *f = '\0';
68 |
69 | return ret;
70 |
71 | }
72 | /* */
73 | static char find_pos(char ch)
74 | {
75 | char *ptr = (char*)strrchr(base, ch);//the last position (the only) in base[]
76 | return (ptr - base);
77 | }
78 | /* */
79 | char *base64_decode(const char *data, int data_len)
80 | {
81 | int ret_len = (data_len / 4) * 3;
82 | int equal_count = 0;
83 | char *ret = NULL;
84 | char *f = NULL;
85 | int tmp = 0;
86 | int temp = 0;
87 | char need[3];
88 | int prepare = 0;
89 | int i = 0;
90 | if (*(data + data_len - 1) == '=')
91 | {
92 | equal_count += 1;
93 | }
94 | if (*(data + data_len - 2) == '=')
95 | {
96 | equal_count += 1;
97 | }
98 | if (*(data + data_len - 3) == '=')
99 | {//seems impossible
100 | equal_count += 1;
101 | }
102 | switch (equal_count)
103 | {
104 | case 0:
105 | ret_len += 4;//3 + 1 [1 for NULL]
106 | break;
107 | case 1:
108 | ret_len += 4;//Ceil((6*3)/8)+1
109 | break;
110 | case 2:
111 | ret_len += 3;//Ceil((6*2)/8)+1
112 | break;
113 | case 3:
114 | ret_len += 2;//Ceil((6*1)/8)+1
115 | break;
116 | }
117 | ret = (char *)malloc(ret_len);
118 | if (ret == NULL)
119 | {
120 | printf("No enough memory.\n");
121 | exit(0);
122 | }
123 | memset(ret, 0, ret_len);
124 | f = ret;
125 | while (tmp < (data_len - equal_count))
126 | {
127 | temp = 0;
128 | prepare = 0;
129 | memset(need, 0, 4);
130 | while (temp < 4)
131 | {
132 | if (tmp >= (data_len - equal_count))
133 | {
134 | break;
135 | }
136 | prepare = (prepare << 6) | (find_pos(data[tmp]));
137 | temp++;
138 | tmp++;
139 | }
140 | prepare = prepare << ((4-temp) * 6);
141 | for (i=0; i<3 ;i++ )
142 | {
143 | if (i == temp)
144 | {
145 | break;
146 | }
147 | *f = (char)((prepare>>((2-i)*8)) & 0xFF);
148 | f++;
149 | }
150 | }
151 | *f = '\0';
152 | return ret;
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/jni/base64.h:
--------------------------------------------------------------------------------
1 | #ifndef _BASE64_H_
2 | #define _BASE64_H_
3 |
4 | static const char base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
5 | char* base64_encode(const char*, int);
6 | char* base64_decode(const char*, int);
7 | static char find_pos(char);
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/app/src/main/jni/com_revo_aesrsa_JniUtil.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_revo_aesrsa_JniUtil */
4 |
5 | #ifndef _Included_com_revo_aesrsa_JniUtil
6 | #define _Included_com_revo_aesrsa_JniUtil
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_revo_aesrsa_JniUtil
12 | * Method: getString
13 | * Signature: ()Ljava/lang/String;
14 | */
15 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getString
16 | (JNIEnv *, jobject);
17 |
18 | /*
19 | * Class: com_revo_aesrsa_JniUtil
20 | * Method: add
21 | * Signature: (II)I
22 | */
23 | JNIEXPORT jint JNICALL Java_com_revo_aesrsa_JniUtil_add
24 | (JNIEnv *, jobject, jint, jint);
25 |
26 | /*
27 | * Class: com_revo_aesrsa_JniUtil
28 | * Method: encrypt
29 | * Signature: (Ljava/lang/String;)Ljava/lang/String;
30 | */
31 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_encrypt
32 | (JNIEnv *, jobject, jstring);
33 |
34 | /*
35 | * Class: com_revo_aesrsa_JniUtil
36 | * Method: decrypt
37 | * Signature: (Ljava/lang/String;)Ljava/lang/String;
38 | */
39 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_decrypt
40 | (JNIEnv *, jobject, jstring);
41 |
42 | /*
43 | * Class: com_revo_aesrsa_JniUtil
44 | * Method: getKeyValue
45 | * Signature: ()Ljava/lang/String;
46 | */
47 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getKeyValue
48 | (JNIEnv *, jobject);
49 |
50 | /*
51 | * Class: com_revo_aesrsa_JniUtil
52 | * Method: getIv
53 | * Signature: ()Ljava/lang/String;
54 | */
55 | JNIEXPORT jstring JNICALL Java_com_revo_aesrsa_JniUtil_getIv
56 | (JNIEnv *, jobject);
57 |
58 | #ifdef __cplusplus
59 | }
60 | #endif
61 | #endif
62 |
--------------------------------------------------------------------------------
/app/src/main/jni/tipc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #ifndef _LIB_TIPC_H
18 | #define _LIB_TIPC_H
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | int tipc_connect(const char *dev_name, const char *srv_name);
25 | int tipc_close(int fd);
26 |
27 | #ifdef __cplusplus
28 | }
29 | #endif
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/app/src/main/libs/arm64-v8a/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/arm64-v8a/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/armeabi-v7a/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/armeabi-v7a/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/armeabi/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/armeabi/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/mips/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/mips/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/mips64/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/mips64/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/x86/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/x86/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/libs/x86_64/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/libs/x86_64/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_cbc.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_cbc.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_cbc.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/aes_cbc.o: jni/aes_cbc.c jni/aes.h \
2 | jni/modes.h
3 |
4 | jni/aes.h:
5 |
6 | jni/modes.h:
7 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_core.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_core.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_core.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/aes_core.o: jni/aes_core.c jni/aes.h \
2 | jni/aes_locl.h
3 |
4 | jni/aes.h:
5 |
6 | jni/aes_locl.h:
7 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_ecb.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_ecb.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/aes_ecb.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/aes_ecb.o: jni/aes_ecb.c jni/aes.h \
2 | jni/aes_locl.h
3 |
4 | jni/aes.h:
5 |
6 | jni/aes_locl.h:
7 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/cbc128.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniLib/cbc128.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniLib/cbc128.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniLib/cbc128.o: jni/cbc128.c jni/modes.h
2 |
3 | jni/modes.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/arm64-v8a/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/arm64-v8a/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/arm64-v8a/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi-v7a/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi-v7a/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/armeabi/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/armeabi/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/armeabi/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/mips64/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/mips64/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/mips64/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/libJniLib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/libJniLib.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/libJniUtil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/libJniUtil.so
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/libstdc++.a:
--------------------------------------------------------------------------------
1 | !
2 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniLib/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniLib/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniLib/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniLib/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniLib/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniLib/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniLib/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniLib/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniLib/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/JniLib.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniUtil/JniLib.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/JniLib.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniUtil/JniLib.o: jni/JniLib.cpp \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/JniUtil.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniUtil/JniUtil.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/JniUtil.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniUtil/JniUtil.o: jni/JniUtil.c \
2 | jni\com_revo_aesrsa_JniUtil.h jni/base64.h jni\aes256.h
3 |
4 | jni\com_revo_aesrsa_JniUtil.h:
5 |
6 | jni/base64.h:
7 |
8 | jni\aes256.h:
9 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/aes256.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniUtil/aes256.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/aes256.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniUtil/aes256.o: jni/aes256.c jni/aes256.h
2 |
3 | jni/aes256.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/base64.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/obj/local/x86_64/objs/JniUtil/base64.o
--------------------------------------------------------------------------------
/app/src/main/obj/local/x86_64/objs/JniUtil/base64.o.d:
--------------------------------------------------------------------------------
1 | ./obj/local/x86_64/objs/JniUtil/base64.o: jni/base64.c jni/base64.h
2 |
3 | jni/base64.h:
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
24 |
32 |
40 |
41 |
42 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | fuckdemo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/revo/aesrsa/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.revo.aesrsa;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | android.useDeprecatedNdk=true
21 |
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stvelzhang/androidRsaAES/30014939e9130afa5cc8aa183614da566e5be367/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Aug 03 12:10:57 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='fuckdemo'
3 |
--------------------------------------------------------------------------------