0

I am trying to canonicalize a few xml documents. As I see it can be achieved by using XmlStar by executing a CMD command

xml c14n --exc-without-comments test_xml.xml > test_xml_canonicalize.xml

My question is can the same result be achieved with C# using XmlDsigC14NTransform class but without RSA signing and if so how?

dmxyler
  • 79
  • 1
  • 1
  • 14

1 Answers1

0

Solution:

     using (MemoryStream msIn = new MemoryStream(Encoding.UTF8.GetBytes(doc.InnerXml)))
     {
         var t = new XmlDsigExcC14NTransform(false);
         t.LoadInput(msIn);
         MemoryStream o = t.GetOutput() as MemoryStream;
         string c14N = Encoding.UTF8.GetString(o?.ToArray() ?? throw new InvalidOperationException());
         Console.WriteLine(c14N);
     }
dmxyler
  • 79
  • 1
  • 1
  • 14