Canonicalisation Question

Canonicalisation Question

Post by Budd » Tue, 21 Sep 2004 23:56:16


I want to know if .Net supports the following features
that I require.
- Canonicalise (c14n) the XML document
- generate a 160-bit binary secure hash from the
canonicalise XML using the SHA-1 algorithm
- encode the binary data using base-64 to produce a 28
character string.

Please note that in Java this available from the 3rd
party libraries such as Apache and Phaos.

Please could you let me know if this can be done directly
within .NET or if there are any third party libaries out


Canonicalisation Question

Post by Nicole Cal » Wed, 22 Sep 2004 06:54:01

The System.Security.Cryptography.Xml.XmlDsigC14NTransform class should do
the trick. See :29:25Z
for an example.

If all you want is a stand-alone hash value,
System.Security.Cryptography.SHA1Managed is probably your best bet.

Perhaps System.Convert.ToBase64String or
System.XML.XmlTextWriter.WriteBase64, depending on what binary data you want
to encode and how you want to perform the encoding.

BTW, if what your overall target is to generate signed XML, you might want
to take a look at the System.Security.Cryptography.Xml.SignedXml class.