Edit

Share via


MachineKey.Encode(Byte[], MachineKeyProtection) Method

Definition

Caution

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.

Encrypts data and/or appends a hash-based message authentication code (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

Parameters

data
Byte[]

The data to encrypt.

protectionOption
MachineKeyProtection

Indicates whether the data parameter should be encrypted and/or hashed.

Returns

The encrypted value, the input value with an HMAC appended, or the result of encrypting the input value with an HMAC appended.

Attributes

Examples

For a code example, see the MachineKey class overview.

Remarks

For information about which encryption and hashing algorithms ASP.NET uses to decrypt and validate the data that is passed in, see machineKey Element (ASP.NET Settings Schema).

Applies to