Help needed calculating/embedding CRC in XML file

  • Thread starter Thread starter StormyTheCat
  • Start date Start date
S

StormyTheCat

Perhaps this is easy, but I'm new to C# am in need of some help.

I need to embed a CRC value into an XML file to be able to detect when the
data contained
therin is corrupted. Calculating the CRC on the DataSet (or an XML
structure) has been the big problem.
This seems like a fairly common problem but I have been unable to find the
solution.

In the world of plain old C, all I needed was the start and end address of
the data in memory
and I could calculate the CRC and store it with the data. This concept
doesn't really exist in
C#. I have a DataSet with the data, but no way to treat it as a byte array
which is what the
one CRC routine I have requires.

In C#, so far I have been using the WriteXML method which wonderfully dumps
a DataSet
to an XML file but doesn't allow me to add anything. I could have a 2nd
table in the dataset
which contains the CRC field and run the calculation on the other table.....

My requirements are only to detect hacking at the file, so a CRC, Hash, MD5,
etc. would all
be workable options. (Although requiring security keys would not be
desired)

Thank you,
Steven
 
Back
Top