I have a byte[] which I need to encode in Base64 and return as SecureString. My current code is as follows:
string privateString = Convert.ToBase64String(byteArray);
SecureString result = new SecureString();
foreach (char c in privateString)
{
result.AppendChar(c);
}
// wipe the byte array...
The problem is that calling Convert.ToBase64String is not secure as it creates a managed string which I can't destroy.
Is there a secure way of doing this?