Suppose there is a WPF program that runs the client through a network connection. The user of the program entered his name: password and in response from the server, the program received a secret key or token, which is used to further work the program with the server. Is there a possibility in .Net to create some kind of protected memory area in which this key can be stored for the duration of the program's session? This is necessary in order to exclude the possibility of "spying" this key during step-by-step decompilation.
SecureStringis that you, as a developer, control the life of such a string (this type is not made disposable for nothing), and its contents are encrypted, while a regularStringcan hang in memory for an arbitrarily long time, so an attacker can save a dump to a file, say, on a flash drive, and then pull out the password in clear text using WinDbg and SOS. That is whySecureStringdoes not have a constructor that accepts a string. Step-by-step decompilation has nothing to do with it. - Raider