C#代码示例
public void MethodA()
{
//using DPAPI to encrpt the sensitive content
System.Security.SecureString password = new
System.Security.SecureString();
char[] pass = { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' };
for (int i = 0; i < pass.Length; i++)
{
password.AppendChar(pass[i]);
}
password.MakeReadOnly();
//pass the encrypted password through memory or file
}
public void MethodB(System.Security.SecureString password)
{
string decryptedPassword = "";
//copy the secure content to a long pointer