MachineKey.Encode(Byte[], MachineKeyProtection) 方法

定义

注意

This method is obsolete and is only provided for compatibility with existing code. It is recommended that new code use the Protect and Unprotect methods instead.

加密数据和/或追加基于哈希的消息身份验证代码(HMAC)。

public:
 static System::String ^ Encode(cli::array <System::Byte> ^ data, System::Web::Security::MachineKeyProtection protectionOption);
public static string Encode(byte[] data, System.Web.Security.MachineKeyProtection protectionOption);
[System.Obsolete("This method is obsolete and is only provided for compatibility with existing code. It is recommended that new code use the Protect and Unprotect methods instead.")]
public static string Encode(byte[] data, System.Web.Security.MachineKeyProtection protectionOption);
static member Encode : byte[] * System.Web.Security.MachineKeyProtection -> string
[<System.Obsolete("This method is obsolete and is only provided for compatibility with existing code. It is recommended that new code use the Protect and Unprotect methods instead.")>]
static member Encode : byte[] * System.Web.Security.MachineKeyProtection -> string
Public Shared Function Encode (data As Byte(), protectionOption As MachineKeyProtection) As String

参数

data
Byte[]

要加密的数据。

protectionOption
MachineKeyProtection

指示参数是否 data 应进行加密和/或哈希处理。

返回

加密值、追加了 HMAC 的输入值,或者使用 HMAC 追加加密输入值的结果。

属性

示例

有关代码示例,请参阅 MachineKey 类概述。

注解

有关 ASP.NET 用于解密和验证传入的数据的加密和哈希算法的信息,请参阅 machineKey 元素(ASP.NET 设置架构)

适用于