简体   繁体   English

适用于 .NET 的 AWS 加密 SDK — 将 AWS-Encryption-SDK 绑定到 C#

[英]AWS Encryption SDK for .NET — Binding AWS-Encryption-SDK to C#

My current project is using the AWS-Encryption-SDK for Python and Node in respective solutions, but we also need a corresponding solution in .NET.我当前的项目在各自的解决方案中使用了适用于 Python 和 Node 的 AWS-Encryption-SDK,但我们也需要在 .NET 中使用相应的解决方案。 However, AWS does not have that SDK in C# yet.但是,AWS 在 C# 中还没有该 SDK。

Does anyone out there have experience with binding the AWS-Encryption-SDK in C/C++ to .NET using PInvoke, Marshalling, and/or DllImport attribute usage?有没有人有使用 PInvoke、Marshalling 和/或 DllImport 属性使用将 C/C++ 中的 AWS-Encryption-SDK 绑定到 .NET 的经验?

Once you have generated DLL using C/C++ code, ensure the generated DLL is copied alongside other DLL's the project is dependent on.使用 C/C++ 代码生成 DLL 后,请确保将生成的 DLL 与项目所依赖的其他 DLL 一起复制。

Add the following code in your C# project which would invoke the Function present in DLL在 C# 项目中添加以下代码,该代码将调用 DLL 中存在的函数

using System.Runtime.InteropServices;
            
[DllImport("GeneratedDLLName.dll", EntryPoint = "FunctionName")]
public static extern string Foo(string payload);

public string InvokeSDKMethod(string payload)
{
  var response = Foo(payload);
  return response;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM