Jnative的调用dll文件 CC++C#
程序员文章站
2022-03-02 16:56:31
...
初次尝试缺发生异常:org.xvolks.jnative.exceptions.NativeException: Function Decrypted not found
说我的方法没有找到,所以查了一下资料,通过确认,是生成dll文件的时候,方法名给优化了,解决办法:
#ifndef __DES3_H__
#define __DES3_H__
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "string.h"
using namespace std;
#define SUCCESS 0
#define FAIL 1
#define DESENCRY 0
#define DESDECRY 1
#define LIBEXPORT_API extern "C" __declspec(dllexport)
一定要把声明继承C的标准,然后生成的dll文件中的方法名就不会改变,就可以解决上面的异常了。
typedef unsigned char UChar;
static const char *tostring="0123456789ABCDEF";
class Des
{
public:
Des(void);
~Des(void);
public:
UChar* Encrypt(UChar *data, UChar *key,int readlen);
UChar* Decrypted(UChar *data,UChar *key,int readlen);
UChar* Encrypt3(UChar *data, UChar *key,unsigned int n ,unsigned int readlen);
UChar* Decrypted3(UChar *data,UChar *key,unsigned int n ,unsigned int readlen);
UChar* EncryptN(UChar *data, UChar **key, unsigned int n_key,unsigned int readlen);
UChar* DecryptedN(UChar *data, UChar **key, unsigned int n_key,unsigned int readlen);
private:
int handle_data(unsigned int *left , int choice);
int makedata(unsigned int *left ,unsigned int *right ,unsigned int number);
int makefirstkey( unsigned int *keyP );
int makekey( unsigned int *keyleft,unsigned int *keyright ,unsigned int number);
};
LIBEXPORT_API unsigned char* DesEncrypt(unsigned char *data,unsigned char *key,int readlen);
LIBEXPORT_API unsigned char* DesDecrypted(unsigned char * data,unsigned char *key,int readlen);
#endif
说我的方法没有找到,所以查了一下资料,通过确认,是生成dll文件的时候,方法名给优化了,解决办法:
#ifndef __DES3_H__
#define __DES3_H__
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include "string.h"
using namespace std;
#define SUCCESS 0
#define FAIL 1
#define DESENCRY 0
#define DESDECRY 1
#define LIBEXPORT_API extern "C" __declspec(dllexport)
一定要把声明继承C的标准,然后生成的dll文件中的方法名就不会改变,就可以解决上面的异常了。
typedef unsigned char UChar;
static const char *tostring="0123456789ABCDEF";
class Des
{
public:
Des(void);
~Des(void);
public:
UChar* Encrypt(UChar *data, UChar *key,int readlen);
UChar* Decrypted(UChar *data,UChar *key,int readlen);
UChar* Encrypt3(UChar *data, UChar *key,unsigned int n ,unsigned int readlen);
UChar* Decrypted3(UChar *data,UChar *key,unsigned int n ,unsigned int readlen);
UChar* EncryptN(UChar *data, UChar **key, unsigned int n_key,unsigned int readlen);
UChar* DecryptedN(UChar *data, UChar **key, unsigned int n_key,unsigned int readlen);
private:
int handle_data(unsigned int *left , int choice);
int makedata(unsigned int *left ,unsigned int *right ,unsigned int number);
int makefirstkey( unsigned int *keyP );
int makekey( unsigned int *keyleft,unsigned int *keyright ,unsigned int number);
};
LIBEXPORT_API unsigned char* DesEncrypt(unsigned char *data,unsigned char *key,int readlen);
LIBEXPORT_API unsigned char* DesDecrypted(unsigned char * data,unsigned char *key,int readlen);
#endif
推荐阅读