I donโt know why the following code will return "Hello native! Th" and not "Hello native! This is from jni load! \ N", can someone tell me?
#include "helloJNI.h"
#include "openssl/aes.h"
#define LEN 1024
jstring jni_text(JNIEnv *env, jclass clz)
{
AES_KEY aesKey;
int result;
const char origin[] = "Hello native! This is from jni load!\n";
char out[LEN];
char outout[LEN];
memset(out, '\0', sizeof(out));
memset(outout, '\0', sizeof(outout));
result = AES_set_encrypt_key((const unsigned char *)"abc123", 256, &aesKey);
LOGE("encypt key result %d\n", result);
AES_encrypt((const unsigned char *)origin, (unsigned char *)out, &aesKey);
LOGE("after encrypt, chars is %s\n", out);
result = AES_set_decrypt_key((const unsigned char *)"abc123", 256, &aesKey);
LOGE("decrypt key result %d\n", result);
AES_decrypt(out, outout, &aesKey);
LOGE("after decrypt, chars is %s\n", outout);
return (*env)->NewStringUTF(env, outout);
}
source
share