问题
It seems there's no blowfish in C# that would do the same as this one.So I decided to use it as an external and if it doesnt work again then translate the whole blowfish in C#. But first I'll try to use as an external.
Could you take a look at the C++ blowfish and tell me if I have to change the function parameters(some of them are LPBYTE,which is not included in C#).
Also,I'd be thankful if you tell me how to use them as an external dll(I have it compiled as a dll already),but the function parameters in C++ are frustrating me.
Edit: I need to call only Initialize,Encode and Decode.
Thanks in advance!
回答1:
I've had a similar problem to this on a previous project. Having looked at the C++ code, it is using ECB as you suspected in your previous post. I think I see the reason why you get different results using Blowfish.NET (Arkain's suggestion). The C++ code casts the inputs into two DWORDs as it enciphers. I believe Blowfish.NET will be doing the right thing by preserving the byte order in the DWORDs it uses internally to encipher.
For example: In the C++ code, the bytes 0102030405060708 become 0x04030201 and 0x08070605. The .NET implementation will be becoming 0x01020304 and 0x05060708.
来源:https://stackoverflow.com/questions/694454/how-to-use-blowfish-in-c-as-an-external-dll-in-c-sharp