Search code examples
.netxmlcryptography3dessymmetric-key

how to wrap/store the key of TripleDESCryptoServiceProvider


I'm using DES encryption, and I want to store the key of TripleDESCryptoServiceProvider.

But the key consists of (Key + IV),

I was trying to save them in an XML file using

XmlTextWriter
Convert.ToBase64String(...)

but there was an exception due to IV contains invalid characters "=" in XML.

Is there a better way to store symmetric cryptography key ?


Solution

  • You can store it in XML if you put it into a CDATA section using the WriteCData method