Android,使用NDK进行C++加密manifest变量
创始人
2024-10-13 08:30:19
0
  1. 在Android Studio中创建新的C++文件,命名为"Crypto.cpp"。

  2. 在"Crypto.cpp"文件中,添加以下代码:

#include 
#include 
#include 
#include 
#include 

#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, "Crypto", __VA_ARGS__)

extern "C" {
    JNIEXPORT jstring JNICALL Java_com_example_myapp_MainActivity_getSecretKey(JNIEnv* env, jobject instance);
};

JNIEXPORT jstring JNICALL Java_com_example_myapp_MainActivity_getSecretKey(JNIEnv* env, jobject instance) {
    std::string key = "my_secret_key";
    std::string encryptedKey = "";
    
    // Perform your encryption algorithm here
    
    return env->NewStringUTF(encryptedKey.c_str());
}
  1. 在AndroidManifest.xml文件中,在"application"标签内添加以下代码:

  1. 在build.gradle文件中,添加以下代码:
android {
    ...
  
    defaultConfig {
        ...
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -O0 -Wall -Werror"
                arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared"
            }
        }
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}

dependencies {
    ...
    implementation 'com.android.support:support-annotations:28.0.0'
}
  1. 在"CMakeLists.txt"文件中,添加以下代码:
# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC or SHARED,
# and provides the relative paths to its source code.

include_directories(src/main/cpp)

add_library(
    native-lib
    SHARED
    src/main/cpp/Crypto.cpp)

find_library(
    log-lib
    log)

# Links your native library against one or more other native libraries.
target_link_libraries(native

相关内容

热门资讯

透视教你!wepoker模拟器... 您好,wepoker到底有没有透视这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
透视透视!wepoker怎么开... 透视透视!wepoker怎么开辅助(透视)佛手大菠萝13道挂哪里,教程攻略(真是有挂)-哔哩哔哩1、...
透视透视!hhpoker真的有... 透视透视!hhpoker真的有透视吗(透视)pokermaster破解版,教程策略(确实有挂)-哔哩...
透视揭露!wepoker能不能... 透视揭露!wepoker能不能透视(透视)wepoker免费透视脚本,教程窍要(有挂详细)-哔哩哔哩...
透视解迷!wpk刷入池率脚本(... 透视解迷!wpk刷入池率脚本(透视)wepoker高级辅助,教程技法(真的有挂)-哔哩哔哩1、玩家可...
透视推荐!wepoker亲友圈... 透视推荐!wepoker亲友圈有用吗(透视)wepoker透视有没有,教程教材(有挂详细)-哔哩哔哩...
透视分享!hhpoker智能辅... 透视分享!hhpoker智能辅助插件(透视)有没有人wepoker,教程教程书(真实有挂)-哔哩哔哩...
透视推荐!pokermaste... 透视推荐!pokermaster脚本(透视)佛手在线大菠萝技巧,教程手段(有挂规律)-哔哩哔哩1、很...
透视分享!哈糖大菠萝开挂(透视... 透视分享!哈糖大菠萝开挂(透视)wpk私人局辅助是真的吗,教程练习(有挂技术)-哔哩哔哩1、这是跨平...
透视关于!newpoker怎么... 透视关于!newpoker怎么安装脚本(透视)大菠萝免费辅助,教程烘培(有挂详细)-哔哩哔哩1、超多...