日期:2014-05-16 浏览次数:20663 次
package com.spidHandle.api; public class SpidHandle { static { System.loadLibrary("spidhandle"); } public String buildSpID(String path, String login_name, String password, String key) { return getSPID(path, login_name, password, key); } public native String getSPID(String path, String login_name, String password, String key); /** * @param args * * 供测试用 */ public static void main(String[] args) { // TODO Auto-generated method stub String keyforMD5 = "A6EIo8tuaKS"; String s = new SpidHandle().buildSpID("/test", "test", "test", keyforMD5); System.out.println(s); } }
javac SpidHandle.java
javah com.spidHandle.api.SpidHandle
#include "com_spidHandle_api_SpidHandle.h" #include <string.h> #include "MD5.h" const static char* version = "1201.01"; JNIEXPORT jstring JNICALL Java_com_spidHandle_api_SpidHandle_getSPID (JNIEnv *env , jobject obj, jstring path, jstring login_name, jstring password, jstring key) { printf("-= com_spidHandle_api_SpidHandle Version %s =- \n", version); char icpid[256]; const char * md5="A6EIo8tuaKS"; const char* login_user = env->GetStringUTFChars(login_name, false); const char* login_pwd = env->GetStringUTFChars(password, false); const char* md5_key = env->GetStringUTFChars(key, false); const char* path_str = env->GetStringUTFChars(path, false); memset(icpid, 0, 256); printf("login_user = %s\n", login_user); printf("path = %s\n", path_str); printf("login_pwd = %s\n", login_pwd); printf("md5_key = %s\n", md5_key); // 不管播放哪个url 直接用这个加密 -_-|| // pPath = "tmes_224"; // 组建加密部分 char *p=icpid; *p=strlen(login_user); p++; strcpy(p,login_user); p+=strlen(login_user); *p=strlen(path_str); p++; strcpy(p,path_str); p+=strlen(path_str); if(strlen(md5_key) > 1) md5 = md5_key; *p=strlen(md5); p++; strcpy(p,md5); p+=strlen(md5); MD5 m1; m1 << md5 << login_user << login_pwd; const char *pmd5 = m1.HexDigest(); // symbian专用 char md5buf[256]; memset(md5buf,0,256); memcpy( md5buf,pmd5,strlen(pmd5) ); // 结束symb