tunga wrote: > Hi UnFleshedOne, > > thanks four your answer. > > and Sorry for the coming silly question (I have never used C++ code > from C# before) but how to create managed > wrapper assembly around unmanaged C++ code??? > > thanks in advance, > >
There are several tutorials around. Here is how to make and use managed assembly: http://msdn.microsoft.com/en-us/library/ms235638.aspx Here is how to use unmanaged code in it: http://www.ondotnet.com/pub/a/dotnet/2003/03/03/mcppp2.html (You might find better ones, I'm posting first remotely related things I found -- google is your friend). - build cryptopp as a static library - make C++.Net assembly dll (class library) linked with cryptopp and exporting your wrapper - make wrapper class exporting functionality you need -- turn off managed code by default (I think it is a project option or something) and use __gc keyword to define your wrapper. - include assembly into your C# project and use your wrapper - ??? - profit! So wrapper would be something like this: public __gc class Wrapper { public: System::String* DoubleRot13(System::String* input); // ... }; And in the function you will do the work. In C# you will call it like this: String encrypted = Wrapper.DoubleRot13("bla bla bla"); Make sure you wrapper exports a way to initialize and terminate CRT -- C# doesn't do that, so you'll have to do it manually before first call to unmanaged code, or suffer when cryptopp tries to use a static variable or something. void Wrapper::InitializeCRT() { __crt_dll_initialize(); } void Wrapper::TerminateCRT() { __crt_dll_terminate(); } If you want to convert managed String into unmanaged std::string you can use that (not sure what will this do with actual Unicode though). Same idea for any other datatypes you need to convert. std::string ConvertString(String* input) { const wchar_t __pin* wch = PtrToStringChars(input); int length = (input->Length+1)*2; char *ch = new char[length]; bool result = wcstombs(ch, wch, length) != -1; std::string output = ch; delete ch; return output; } There might be some specific compiler and linker flags you have to set, but I don't remember now. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [EMAIL PROTECTED] More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
