如何在 SQL Server 数据库中安全地存储 API 凭据?

use*_*205 5 c# sql-server cryptography

在我的 Windows 服务中,我需要能够检索存储在同一网络上的 SQL Server 2012 数据库中的第三方 REST API 的凭据。我的每个客户可能都分配有不同的 API 凭证。例如:

Customer Name | API ID | API Password In Plain Text
-----------------------------------------------------
Customer 1      1234     somepassword
Customer 2      1234     somepassword
Customer 3      5678     anotherpassword
Run Code Online (Sandbox Code Playgroud)

在此服务的第一次迭代中,所有客户都使用相同的 API 凭据,并使用SectionInformation.ProtectSection在 Windows 服务的 app.config 中对其进行加密。

我是否只使用 .NET 框架提供的加密/解密方法之一并将该值存储在数据库中?例如,此处提供的解决方案之一:Encrypting & Decrypting a String in C# ? 我可以研究任何建议或其他解决方案?

use*_*205 1

根据 @SyntaxGoonoo 的建议,我计划使用数据保护 API (DAPI) 提供的ProtectedData 类。我将设置DataProtectionScope作为与 Windows 服务关联的 CurrentUser 运行,以解密 SQL 数据库中的凭据。我可能必须创建另一个应用程序来加密凭据并将其存储在数据库中(使用相同的用户上下文)。

这里有一些额外的资源: