MachineKey.Unprotect(Byte[], String[]) Method

Definition

Unprotects the specified data, which was protected by the Protect(Byte[], String[]) method.

C#
public static byte[] Unprotect(byte[] protectedData, params string[] purposes);

Parameters

protectedData
Byte[]

The ciphertext data to unprotect.

purposes
String[]

A list of purposes that describe what the data is meant for. This must be the same value that was passed to the Protect(Byte[], String[]) method when the data was protected.

Returns

Byte[]

The plaintext data.

Exceptions

The protectedData parameter is null.

The purposes array contains one or more white-space-only entries.

Possible causes include the following:

  • The protected data was tampered with.

  • The value of the purposes parameter is not the same as the value that was specified when the data was protected.

  • The application is deployed to more than one server and is using auto-generated encryption keys.

Remarks

For information about this method, see the Protect method.

Applies to

Product Versions
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1