我在使用C#
的流程中添加密码凭据时遇到问题目前看起来如下:
char[] passwordChars = {'x', 'x', 'x', '@', 'x', 'x', 'x', 'x'} ;
System.Security.SecureString ssPwd = new SecureString(passwordChars, passwordChars.Length);
我想知道如何继续将它从char []转换为char *。
答案 0 :(得分:1)
从SecureString documentation开始:
System.Security.SecureString ssPwd;
char[] passwordChars = {'x', 'x', 'x', '@', 'x', 'x', 'x', 'x'} ;
fixed(char* pChars = passwordChars)
{
ssPwd = new SecureString(pChars, chars.Length);
}
//Don't forget to dispose of your string after you're done with it:
ssPwd.Dispose();
答案 1 :(得分:1)
char[] passwordChars = { 'x', 'x', 'x', '@', 'x', 'x', 'x', 'x' };
System.Security.SecureString ssPwd = new SecureString();
foreach (var c in passwordChars)
{
ssPwd.AppendChar(c);
}
ssPwd.MakeReadOnly();