FWIW here's .NET's description of its SecureString class
(
http://msdn.microsoft.com/en-us/library/system.security.securestring.aspx)
which is automatically encrypted and memory-pinned, for when you want
to keep this kind of information around in memory:
"An instance of the System.String class is both immutable and, when no
longer needed, cannot be programmatically scheduled for garbage
collection; that is, the instance is read-only after it is created and
it is not possible to predict when the instance will be deleted from
computer memory. Consequently, if a String object contains sensitive
information such as a password, credit card number, or personal data,
there is a risk the information could be revealed after it is used
because your application cannot delete the data from computer memory.
A SecureString object is similar to a String object in that it has a
text value. However, the value of a SecureString object is
automatically encrypted, can be modified until your application marks
it as read-only, and can be deleted from computer memory by either
your application or the .NET Framework garbage collector."
Of course, this requires the OS hiding the encryption key somehow/in
kernel space. And of course, constructing a SecureString from
something that used to be a string, or getting a string with
ToString(), causes the same problem as before.
http://blogs.msdn.com/b/shawnfa/archive/2004/05/27/143254.aspx
http://blogs.msdn.com/b/shawnfa/archive/2004/05/17/133650.aspx
On Mon, May 21, 2012 at 2:28 AM, Patrick Mylund Nielsen