MachineKey.Encode(Byte[], MachineKeyProtection) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
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 Element (ASP.NET Settings Schema) 。