I am trying to remove any traces of a normal string from memory, to do so I am creating an instance of SecureString
from a reference of the normal string. Like so:
public static unsafe void Burn(this string input)
{
fixed (char* c = input)
{
var secure = new SecureString(c, input.Length);
secure.Dispose();
}
}
The problem is that even after calling the dispose method the contents of input
are non-changed. From my understanding the SecureString
instance should reference the input
address and therefore clean if from memory upon Dispose()
call. What am I missing?