How to use blowfish in C++ as an external dll in C#

て烟熏妆下的殇ゞ 提交于 2019-12-24 23:25:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!