在 CLR 项目中,我将 AesManaged 类的输出作为 16 字节数组
array<unsigned char>^ result = msEncrypt->ToArray();
但是我需要将其转换为像这样定义的 unsigned char 类型的数组
unsigned char buff[16];
编辑:我确实尝试过这个,但它给出了错误(没有带有这些参数的方法签名,尽管有一个)
System::Runtime::InteropServices::Marshal::Copy(result, 0, buff, 16);
还有这个
buff = reinterpret_cast<unsigned char>(&result);
但错误是表达式必须是可修改的左值
最佳答案
根据这个MSDN documentation我用过这个,看起来很有效
pin_ptr<unsigned char>buff = &result[0];
关于c++-cli - 如何将 array<unsigned char> 转换为 unsigned char[]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32938866/