System.Security.Cryptography.ProtectedData.Unprotect Method

Decrypts the data in a specified byte array and returns a byte array that contains the decrypted data.

Syntax

public static byte[] Unprotect (byte[] encryptedData, byte[] optionalEntropy, DataProtectionScope scope)

Parameters

encryptedData
A byte array containing data encrypted using the ProtectedData.Protect(Byte[], Byte[], DataProtectionScope) method.
optionalEntropy
An optional additional byte array that was used to encrypt the data, or null if the additional byte array was not used.
scope
One of the enumeration values that specifies the scope of data protection that was used to encrypt the data.

Returns

A byte array representing the decrypted data.

Remarks

This method can be used to unprotect data that was encrypted using the ProtectedData.Protect(Byte[], Byte[], DataProtectionScope) method. If the optionalEntropy parameter was used during encryption, it must be supplied to unencrypt the data.

Note:

If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method.

Requirements

Namespace: System.Security.Cryptography
Assembly: System.Security (in System.Security.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0