|
@@ -41,18 +41,25 @@ static jstring GetParam(JNIEnv *env, jobject thiz, jstring key) {
|
|
|
static jstring InvokeJob(JNIEnv *env, jobject thiz, jobject context, jstring key, jstring data) {
|
|
|
const char *key_ = env->GetStringUTFChars(key, JNI_FALSE);
|
|
|
const char *data_ = env->GetStringUTFChars(data, JNI_FALSE);
|
|
|
-// Json::Value root = ToolKit::ToJsonObject(data_);
|
|
|
-// if (root.)
|
|
|
-// LOGD("aaaaa , %s", data_);
|
|
|
-// LOGD("json str %s", root.asCString());
|
|
|
-// std::string raw = ToolKit::ToJsonString(root);
|
|
|
-// LOGD("aes key : %s", raw);
|
|
|
- char *enc = AesUtils::Encrypt(data_, reinterpret_cast<const uint8_t *>(key_));
|
|
|
- jstring result = ToolKit::GetJString(env, enc);
|
|
|
+
|
|
|
+ //添加公共参数
|
|
|
+ Json::Value root = ToolKit::ToJsonObject(data_);
|
|
|
+ root["common"] = CommMap::GetInstance()->comm_params;
|
|
|
+
|
|
|
+ //生成aes key
|
|
|
+// char *raw_key = AesUtils::GetRawKey();
|
|
|
+// std::string md5_key = md5(raw_key);
|
|
|
+// auto *key64= static_cast<char *>(malloc(65));
|
|
|
+// memset(key64,0,64);
|
|
|
+// sprintf(key64,"%s%s",md5_key,reverse(md5_key.begin(),md5_key.end()))
|
|
|
+// std::string aes_key=md5()
|
|
|
+ LOGD("test : %s", ToolKit::StrReverse(key_));
|
|
|
+ char *p = AesUtils::Encrypt(ToolKit::ToJsonString(root).c_str(), reinterpret_cast<const uint8_t *>(key_));
|
|
|
+ jstring result = ToolKit::GetJString(env, p);
|
|
|
env->ReleaseStringUTFChars(key, key_);
|
|
|
env->ReleaseStringUTFChars(data, data_);
|
|
|
// delete (raw);
|
|
|
- free(enc);
|
|
|
+ free(p);
|
|
|
return result;
|
|
|
|
|
|
// std::string enc = RequestKit::EncryptRequest2(env, context, data);
|
|
@@ -102,6 +109,12 @@ static jstring ParseJob(JNIEnv *env, jobject thiz, jobject context, jstring key,
|
|
|
// return env->NewStringUTF("");
|
|
|
}
|
|
|
|
|
|
+static jstring Test(JNIEnv *env, jobject thiz) {
|
|
|
+ char *key = AesUtils::GetRawKey();
|
|
|
+ jstring result = ToolKit::GetJString(env, key);
|
|
|
+ free(key);
|
|
|
+ return result;
|
|
|
+}
|
|
|
|
|
|
static JNINativeMethod gMethod[] = {
|
|
|
{"initSdkDrive", "(Landroid/content/Context;)V", (void *) InitSdkDrive},
|
|
@@ -109,6 +122,7 @@ static JNINativeMethod gMethod[] = {
|
|
|
{"getParam", "(Ljava/lang/String;)Ljava/lang/String;", (void *) GetParam},
|
|
|
{"invokeJob", "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void *) InvokeJob},
|
|
|
{"parseJob", "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void *) ParseJob},
|
|
|
+ {"test", "()Ljava/lang/String;", (void *) Test},
|
|
|
};
|
|
|
|
|
|
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|