ProtectedConfigurationProvider.Encrypt(XmlNode) 方法

定义

加密从配置文件传递的 XmlNode 对象。Encrypts the passed XmlNode object from a configuration file.

public:
 abstract System::Xml::XmlNode ^ Encrypt(System::Xml::XmlNode ^ node);
public abstract System.Xml.XmlNode Encrypt (System.Xml.XmlNode node);
abstract member Encrypt : System.Xml.XmlNode -> System.Xml.XmlNode
Public MustOverride Function Encrypt (node As XmlNode) As XmlNode

参数

node
XmlNode

要加密的 XmlNode 对象。The XmlNode object to encrypt.

返回

XmlNode

包含已加密数据的 XmlNode 对象。The XmlNode object containing encrypted data.

示例

下面的示例演示如何使用 Encrypt 执行自定义加密。The following example shows how to use Encrypt to perform custom encryption.

// Performs encryption.
public override XmlNode Encrypt(XmlNode node)
{
    string encryptedData = EncryptString(node.OuterXml);

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.PreserveWhitespace = true;
    xmlDoc.LoadXml("<EncryptedData>" +
        encryptedData + "</EncryptedData>");

    return xmlDoc.DocumentElement;
}
' Performs encryption.
Public Overrides Function Encrypt( _
ByVal node As XmlNode) As XmlNode
    Dim encryptedData As String = _
    EncryptString(node.OuterXml)

    Dim xmlDoc As New XmlDocument()
    xmlDoc.PreserveWhitespace = True
    xmlDoc.LoadXml( _
    ("<EncryptedData>" + encryptedData + _
    "</EncryptedData>"))

    Return xmlDoc.DocumentElement
End Function 'Encrypt

实施者说明

重写此方法以执行自定义加密。Override this method to perform custom encryption.

适用于