1.C++ 调用Base64中的 public static String encodeToString(byte[] input, int flags)方法 返回的时String
jclass MessageDigestClass = env->FindClass("android/util/Base64");
jmethodID MessageDigestClass_getInstance = env->GetStaticMethodID(MessageDigestClass, "encodeToString", "([BI)Ljava/lang/String;");
jstring MessageDigestObj = (jstring)env->CallStaticObjectMethod(MessageDigestClass, MessageDigestClass_getInstance, cipher,2);
char asts =(char)env->GetStringUTFChars(MessageDigestObj,0);
LOGE("%s", asts);
LOGE("%s", asts);
//解密 使用Base64中的public static byte[] decode(String str, int flags) 返回是byte[]
jmethodID Base64Class_decode = env->GetStaticMethodID(Base64Class, "decode", "(Ljava/lang/String;I)[B");
jbyteArray decodeArray = (jbyteArray)env->CallStaticObjectMethod(Base64Class, Base64Class_decode, MessageDigestObj,2);
char *chars = NULL;
jbyte *bytes;
bytes = env->GetByteArrayElements(decodeArray, 0);
int chars_len = env->GetArrayLength(decodeArray);
chars = new char[chars_len + 1];
memset(chars, 0, chars_len + 1);
memcpy(chars, bytes, chars_len);
chars[chars_len] = 0;
env->ReleaseByteArrayElements(decodeArray, bytes, 0);
LOGE("--------------");