Corrected XmlDocument variable name (#566)

* Corrected variable name

* Update snippets/csharp/VS_Snippets_CLR/HowToVerifyXMLDocumentRSA/cs/sample.cs

Co-Authored-By: rpetrusha <ronpet@microsoft.com>

* Corrected case of Key
This commit is contained in:
Ron Petrusha 2019-01-14 16:55:57 -08:00 коммит произвёл GitHub
Родитель 2d08bfdc25
Коммит 04c7473530
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 17 добавлений и 29 удалений

Просмотреть файл

@ -54,29 +54,26 @@ public class VerifyXML
}
}
// Verify the signature of an XML file against an asymmetric
// algorithm and return the result.
public static Boolean VerifyXml(XmlDocument Doc, RSA Key)
public static Boolean VerifyXml(XmlDocument xmlDoc, RSA key)
{
// Check arguments.
if (Doc == null)
throw new ArgumentException("Doc");
if (Key == null)
throw new ArgumentException("Key");
if (xmlDoc == null)
throw new ArgumentException("xmlDoc");
if (key == null)
throw new ArgumentException("key");
// Create a new SignedXml object and pass it
// the XML document class.
// <snippet5>
SignedXml signedXml = new SignedXml(Doc);
SignedXml signedXml = new SignedXml(xmlDoc);
// </snippet5>
// Find the "Signature" node and create a new
// XmlNodeList object.
// <snippet6>
XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Signature");
// </snippet6>
// Throw an exception if no signature was found.
@ -100,8 +97,8 @@ public class VerifyXML
// Check the signature and return the result.
// <snippet8>
return signedXml.CheckSignature(Key);
return signedXml.CheckSignature(key);
// </snippet8>
}
}
// </snippet1>
// </snippet1>

Просмотреть файл

@ -4,11 +4,7 @@ Imports System.Security.Cryptography
Imports System.Security.Cryptography.Xml
Imports System.Xml
Module VerifyXML
Sub Main(ByVal args() As String)
Try
' Create a new CspParameters object to specify
@ -44,32 +40,27 @@ Module VerifyXML
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
' Verify the signature of an XML file against an asymmetric
' algorithm and return the result.
Function VerifyXml(ByVal Doc As XmlDocument, ByVal Key As RSA) As [Boolean]
Function VerifyXml(ByVal xmlDoc As XmlDocument, ByVal key As RSA) As [Boolean]
' Check arguments.
If Doc Is Nothing Then
Throw New ArgumentException("Doc")
If xmlDoc Is Nothing Then
Throw New ArgumentException("xmlDoc")
End If
If Key Is Nothing Then
Throw New ArgumentException("Key")
If key Is Nothing Then
Throw New ArgumentException("key")
End If
' Create a new SignedXml object and pass it
' the XML document class.
' <snippet5>
Dim signedXml As New SignedXml(Doc)
Dim signedXml As New SignedXml(xmlDoc)
' </snippet5>
' Find the "Signature" node and create a new
' XmlNodeList object.
' <snippet6>
Dim nodeList As XmlNodeList = Doc.GetElementsByTagName("Signature")
Dim nodeList As XmlNodeList = xmlDoc.GetElementsByTagName("Signature")
' </snippet6>
' Throw an exception if no signature was found.
If nodeList.Count <= 0 Then
@ -89,7 +80,7 @@ Module VerifyXML
' </snippet7>
' Check the signature and return the result.
' <snippet8>
Return signedXml.CheckSignature(Key)
Return signedXml.CheckSignature(key)
' </snippet8>
End Function
End Module