在Gradle上保存重要的按键是否安全? [英] Does it safe to save important keys on gradle?
本文介绍了在Gradle上保存重要的按键是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序中有一些重要的键,我想知道它放在哪里的最佳位置。我也启用了我的proguard,但是当我反编译应用程序时,钢键可见,我正在考虑将它们放在gradle上。 解决方案
创建一个文件夹jni(在main中)并创建两个文件。
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library(hide_key SHARED
hide_key.c)
#包含hide_key所需的库lib
target_link_libraries (hide_key
android
log)
复制并粘贴到CMakeLists.txt 。
#include< string.h>
#include< jni.h>
JNIEXPORT jstring JNICALL
Java _ / *替换为包* / _ stringFromJNI(JNIEnv * env,
jobject实例){
return(* env) - > NewStringUTF (env,钥匙在这里);
}
在hide_key.c中。
然后在build.gradle
android {
externalNativeBuild {
cmake {
pathsrc / main / jni / CMakeLists.txt
}
}
}
然后在你的代码中做这个来获得密钥。
static {
System .loadLibrary( hide_key);
}
public native String stringFromJNI();
I have some important keys in my application and I want to know where its the best place to put them. I also have enabled my proguard but when I decompile the app the keys steel visible, I was thinking put them on gradle.
解决方案
Create a folder jni(inside main) and create two files.
- hide_key.c.
- CMakeLists.txt
CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library(hide_key SHARED
hide_key.c)
# Include libraries needed for hide_key lib
target_link_libraries(hide_key
android
log)
Copy above and paste in CMakeLists.txt.
#include <string.h>
#include <jni.h>
JNIEXPORT jstring JNICALL
Java_/*replace with package*/_stringFromJNI(JNIEnv *env,
jobject instance) {
return (*env)->NewStringUTF(env, "key here");
}
This in hide_key.c.
Then in build.gradle
android{
externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
}
}
}
Then in your code do this to get the key.
static {
System.loadLibrary("hide_key");
}
public native String stringFromJNI();
这篇关于在Gradle上保存重要的按键是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文