int DllExport pke_decrypt(char *input1,char *input2,char* &vout)
{
std::string in1(input1);
std::string in2(input2);
std::string out = in1 + in2;
vout = new char[out.length() + 3];
memset(vout, 0, out.length() + 3);
//strcpy_s(vout, out.length(), out.c_str());
for (int i=0; i<out.length(); ++i)
{
vout[i] = out[i];
}
vout[out.length()]='\0';
printf("C++ in1=%s\n",in1.c_str());
printf("C++ in2=%s\n",in2.c_str());
printf("C++ out=%s\n",vout);
return 0;
}
def pke_decrypt(self, input1, input2):
global _p
v = ctypes.c_char_p()
self.mydll.pke_decrypt(input1.encode('utf-8'), input2.encode('utf-8'), ctypes.byref(v))
print('python ',(v.value).decode("utf-8"))
return
in1 = 'hello'
in2 = ' world'
outstr = ''
self.pke_decrypt(in1, in2)
Python调用C++接口, 参数传递
最新推荐文章于 2024-03-20 11:00:32 发布