Convert String to SecureString

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

How to convert String to SecureString?

13条回答
  •  轮回少年
    2020-12-12 16:37

    You don't. The whole reason for using the SecureString object is to avoid creating a string object (which is loaded into memory and kept there in plaintext until garbage collection). However, you can add characters to a SecureString by appending them.

    var s = new SecureString();
    s.AppendChar('d');
    s.AppendChar('u');
    s.AppendChar('m');
    s.AppendChar('b');
    s.AppendChar('p');
    s.AppendChar('a');
    s.AppendChar('s');
    s.AppendChar('s');
    s.AppendChar('w');
    s.AppendChar('d');
    

提交回复
热议问题