O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create an XML Digital Signature

Problem

You need to sign part of an XML document according the XML Signatures standard.

Solution

Use the classes in the System.Security.Cryptography.Xml namespace.

Discussion

You can apply the hashing and signing techniques in recipe Encrypt an Object and Verify That Data Hasn’t Changed to encrypt XML content in a file or a byte array, just as you would create a hash for any other type of data. However, this approach introduces several limitations:

  • There’s no easy way to create a hash code and then make the resulting document (XML source and hash code) into a valid XML document.

  • Minor differences in XML documents (such as the addition of white space) will change the hash code, even though they have no effect on how the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required