我正在尝试使用crypto++编译一个项目。我的项目正在使用 clr ,当我尝试编译代码时,最终出现以下错误:
'main' : this function cannot be compiled as managed, consider using #pragma unmanaged
'int main(cli::array<Type> ^)' : managed type or function cannot be used in an unmanaged function
我的项目正在使用clr
,我正在/MD
用作运行时库。我在编译crypto++时设置了相同的参数。
编辑:我的主要功能
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
// Generate keys
AutoSeededRandomPool rng;
InvertibleRSAFunction params;
params.GenerateRandomWithKeySize( rng, 1536 );
RSA::PrivateKey privateKey( params );
RSA::PublicKey publicKey( params );
std::string plain="RSA Encryption", cipher, recovered;
// Encryption
RSAES_OAEP_SHA_Encryptor e( publicKey );
StringSource( plain, true,
new PK_EncryptorFilter( rng, e,
new StringSink( cipher )
) // PK_EncryptorFilter
); // StringSource
// Decryption
RSAES_OAEP_SHA_Decryptor d( privateKey );
StringSource( cipher, true,
new PK_DecryptorFilter( rng, d,
new StringSink( recovered )
) // PK_DecryptorFilter
); // StringSource
assert( plain == recovered );
std::cin.ignore();
return 0;
}