I am having trouble in adding password credentials in a process using C#
Currently it looks as the following:
char[] passwordChars = {'x', 'x', 'x', '@', 'x', 'x', 'x', 'x'} ;
System.Security.SecureString ssPwd = new SecureString(passwordChars, passwordChars.Length);
I am wondering how I go on about converting it to char* from char[].
Taken right from the 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();
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.