├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── strings.xml │ │ │ └── colors.xml │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── github │ │ └── maxwell │ │ └── nc │ │ └── nativestrencrypt │ │ └── MainActivity.java ├── build.gradle └── proguard-rules.pro ├── encryptlib ├── .gitignore ├── src │ └── main │ │ ├── jni │ │ ├── Application.mk │ │ ├── Android.mk │ │ ├── DecryptAPI.h │ │ ├── Tools.h │ │ ├── EncryptUtils.h │ │ ├── DecryptAPI.cpp │ │ ├── EncryptUtils.cpp │ │ └── Tools.cpp │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ ├── libs │ │ ├── x86 │ │ │ └── libmaxwell_encrypt.so │ │ ├── armeabi │ │ │ └── libmaxwell_encrypt.so │ │ └── armeabi-v7a │ │ │ └── libmaxwell_encrypt.so │ │ └── java │ │ └── com │ │ └── github │ │ └── maxwell │ │ └── nc │ │ └── encryptlib │ │ └── EncryptUtils.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── preview ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg └── 5.jpg ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /encryptlib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':encryptlib' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /encryptlib/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi armeabi-v7a x86 -------------------------------------------------------------------------------- /preview/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/preview/1.jpg -------------------------------------------------------------------------------- /preview/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/preview/2.jpg -------------------------------------------------------------------------------- /preview/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/preview/3.jpg -------------------------------------------------------------------------------- /preview/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/preview/4.jpg -------------------------------------------------------------------------------- /preview/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/preview/5.jpg -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | NativeStrEncrypt 3 | 4 | -------------------------------------------------------------------------------- /encryptlib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | encryptlib 3 | 4 | -------------------------------------------------------------------------------- /encryptlib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /encryptlib/src/main/libs/x86/libmaxwell_encrypt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/encryptlib/src/main/libs/x86/libmaxwell_encrypt.so -------------------------------------------------------------------------------- /encryptlib/src/main/libs/armeabi/libmaxwell_encrypt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/encryptlib/src/main/libs/armeabi/libmaxwell_encrypt.so -------------------------------------------------------------------------------- /encryptlib/src/main/libs/armeabi-v7a/libmaxwell_encrypt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxwell-nc/AndroidNativeStringEncryptLibrary/HEAD/encryptlib/src/main/libs/armeabi-v7a/libmaxwell_encrypt.so -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /encryptlib/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | LOCAL_MODULE := maxwell_encrypt 4 | LOCAL_SRC_FILES := EncryptUtils.cpp DecryptAPI.cpp Tools.cpp 5 | LOCAL_CFLAGS := -fvisibility=hidden -fno-stack-protector -Wall -Wno-address-of-array-temporary 6 | LOCAL_LDLIBS += -llog 7 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /encryptlib/src/main/java/com/github/maxwell/nc/encryptlib/EncryptUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.maxwell.nc.encryptlib; 2 | 3 | /** 4 | * 字符串加密工具类 5 | */ 6 | public class EncryptUtils { 7 | 8 | static { 9 | System.loadLibrary("maxwell_encrypt"); 10 | } 11 | 12 | /** 13 | * 获取密码例子
14 | * 原密码:abcefg 15 | */ 16 | public static native String getSamplePass(Object context); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /encryptlib/src/main/jni/DecryptAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // 加密API 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "Tools.h" 11 | 12 | #if DEBUG 13 | /** 14 | * 加密接口 15 | */ 16 | __attribute__((section (".datas"))) 17 | char* encrypt(char* content,char *password); 18 | #endif 19 | 20 | /** 21 | * 解密接口 22 | */ 23 | __attribute__((section (".datas"))) 24 | char* decrypt(char* content,char *password); -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.github.maxwell.nc.nativestrencrypt" 8 | minSdkVersion 16 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation project(':encryptlib') 24 | } 25 | -------------------------------------------------------------------------------- /encryptlib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 16 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | sourceSets.main { 15 | jni.srcDirs = [] 16 | jniLibs.srcDir 'src/main/libs' 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | } 29 | -------------------------------------------------------------------------------- /encryptlib/src/main/jni/Tools.h: -------------------------------------------------------------------------------- 1 | // 2 | // 工具类头文件 3 | // 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | //是否需要打印Log 12 | #define DEBUG false 13 | 14 | //打印标签 15 | #define TAG "JNI_LOG" 16 | 17 | #if DEBUG 18 | #define logInfo(...) __android_log_print(ANDROID_LOG_INFO,TAG ,__VA_ARGS__) 19 | #define logErr(...) __android_log_print(ANDROID_LOG_ERROR,TAG ,__VA_ARGS__) 20 | #else 21 | #define logInfo(...) 22 | #define logErr(...) 23 | #endif 24 | 25 | void HexStr2CharStr(char *pszHexStr, int iSize, char *pucCharStr); 26 | void CharStr2HexStr(char *pucCharStr, int iSize, char *pszHexStr); 27 | bool validApp(JNIEnv * env,jobject contextObject); 28 | char* nstrcat(const char* ,...); 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |