【发布时间】:2020-04-05 14:36:38
【问题描述】:
我有一个类似的 dll 库
void Decrypt(BYTE* RoundKey, BYTE* Data){...}
这是一个简单的解密函数,它接收一个密钥和数据指针,只解密数据。 我想在 C# 中使用这个 dll,所以我写了一个示例测试代码
[DllImport("test.dll", CallingConvention = CallingConvention.Cdecl)]
extern private static unsafe void decrypt(byte* RoundKey, byte* Data);
static unsafe void Main(string[] args) {
public static byte[] Key = {0x00, ....};
public static byte[] data = {0x00, ....};
decrypt(&Key, &data);
}
而且这段代码没有被编译。我想了解如何在 C# 中使用这个 dll?
【问题讨论】:
-
有几件事...您不能声明
public static局部变量。此外,方法名称区分大小写,decrypt!=Decrypt。