小编use*_*061的帖子

AES_encrypt/AES_decrypt 仅返回消息的一部分

我不知道为什么下面的代码会返回“Hello native!Th”而不是“Hello native!This is from jni load!\n”,有人可以提示一下吗?

#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); /* is 0 */
    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 …
Run Code Online (Sandbox Code Playgroud)

java-native-interface openssl

5
推荐指数
1
解决办法
1082
查看次数

标签 统计

java-native-interface ×1

openssl ×1