Convert String to SecureString

前端 未结 13 1930
粉色の甜心
粉色の甜心 2020-12-12 15:43

How to convert String to SecureString?

13条回答
  •  醉酒成梦
    2020-12-12 16:28

    Here is a cheap linq trick.

                SecureString sec = new SecureString();
                string pwd = "abc123"; /* Not Secure! */
                pwd.ToCharArray().ToList().ForEach(sec.AppendChar);
                /* and now : seal the deal */
                sec.MakeReadOnly();
    

提交回复
热议问题