如何在 C++ 中使用河豚 作为 C# 中的外部 dll

发布于 2024-07-15 09:41:15 字数 430 浏览 4 评论 0原文

C# 中似乎没有一个河豚能与这个做同样的事情。所以我决定使用它作为外部,如果它再次不起作用,则将整个河豚翻译为 C#。 但首先我会尝试将其用作外部。

你能看一下 C++ 河豚 并告诉我是否必须更改函数参数(其中一些参数)是 LPBYTE,C# 中不包含)。

另外,如果你告诉我如何将它们用作外部 dll(我已经将其编译为 dll),我将不胜感激,但 C++ 中的函数参数让我感到沮丧。

编辑: 我只需要调用初始化、编码和解码。

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你列表最软的妹 2024-07-22 09:41:15

我在之前的项目中也遇到过类似的问题。
查看 C++ 代码后,正如您在上一篇文章中怀疑的那样,它正在使用 ECB。
我想我明白为什么使用 Blowfish.NET 得到不同结果的原因(Arkain 的建议)。 C++ 代码在加密时将输入转换为两个 DWORD。 我相信 Blowfish.NET 将通过保留内部使用的 DWORD 中的字节顺序来做正确的事情来加密。

例如:
在C++代码中,字节0102030405060708变成0x04030201和0x08070605。
.NET 实现将变为 0x01020304 和 0x05060708。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文