Signing an XML

Posted: October 10, 2008 in XML

public void sign()
{
XmlDocument doc = new XmlDocument();
doc.Load(@”C:\Inetpub\wwwroot\NumberVerfication\NumberVerification.xml”);

SignedXml signer = new SignedXml(doc);
RSA key = new RSACryptoServiceProvider();

signer.KeyInfo = new KeyInfo();
signer.KeyInfo.AddClause(new RSAKeyValue(key));
signer.SigningKey = key;

Reference orderRef = new Reference(“”);
orderRef.AddTransform(new XmlDsigEnvelopedSignatureTransform());

signer.AddReference(orderRef);
signer.ComputeSignature();

doc.DocumentElement.AppendChild(signer.GetXml());
txtOutput.Text = doc.InnerText;
doc.Save(@”E:\Numberverification.xml”);
}

This method will give the signed XML. This uses RSA Crtytography Algorithm.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s