How do I use SecureString securely?

后端 未结 2 1651
暖寄归人
暖寄归人 2021-02-04 00:17

All of the examples I have seen end up converting a SecureString back to a standard string before using it, defeating the object. What\'s a good way of using a secure string wit

2条回答
  •  广开言路
    2021-02-04 00:41

    I think the MSDN Page describing the SecureString says it best:

    Represents text that should be kept confidential.

    SecureStrings are not meant to be used like strings. They are meant to be limited-access holders of information that should be subject to increased security.

    If you want to modify the contents of a SecureString, all of the necessary methods are there.

    However, if you need to get the value of the secure string, you must ToString() as no other methods are exposed to do this.

    In other words, don't use SecureStrings like strings.

提交回复
热议问题