我刚刚包装了一个头文件(.h)并创建了它。函数Encrypt接受char*bb,然后使用memcpy()填充它。如果我想从c代码调用这个函数,我必须做(char*bb=(char*)new char[200];Encrypt(…,…,…,bb);)。如何从python调用它?python中(char*bb=(char*)new char[200];)的等价物是什么?在int Encrypt (string key, string iv, string plaintext, char* bb)
{
std::string ciphertext;
CryptoPP::AES::Encryption aesEncryption((byte *)key.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, (byte *)iv.c_str() );
CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast( plaintext.c_str() ), plaintext.length() );
stfEncryptor.MessageEnd();
memcpy(bb,ciphertext.c_str(), ciphertext.size());
return ciphertext.size();
};
从c调用Encrypt():
^{pr2}$
我在python中使用create_string_buffer(“,400),但它不起作用。在