Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

ProtectedData Class

Provides methods for encrypting and decrypting data. This class cannot be inherited.

System.Object
  System.Security.Cryptography.ProtectedData

Namespace:  System.Security.Cryptography
Assembly:  mscorlib.Extensions (in mscorlib.Extensions.dll)
public static class ProtectedData

The ProtectedData type exposes the following members.

  NameDescription
Public methodStatic memberSupported by Silverlight for Windows PhoneProtectEncrypts the data in a specified byte array and returns a byte array that contains the encrypted data.
Public methodStatic memberSupported by Silverlight for Windows PhoneUnprotectDecrypts the data in a specified byte array and returns a byte array that contains the decrypted data.
Top

This class provides access to the Data Protection API (DPAPI). This is a service that is provided by the operating system and does not require additional libraries. It provides protection using the user or machine credentials to encrypt or decrypt data.

Silverlight for Windows Phone In Silverlight for Windows Phone, both the user and machine credentials are used to encrypt or decrypt data.

The class consists of two wrappers for the unmanaged DPAPI, Protect and Unprotect. These two methods can be used to encrypt and decrypt data such as passwords, keys, and connection strings.

If you use these methods during impersonation, you may receive the following error: "Key not valid for use in specified state." This occurs because the DPAPI stores the key data in user profiles. If the profile is not loaded, DPAPI won’t be able to perform the decryption. To prevent this error, load the profile of the user you want to impersonate before calling either method. Using DPAPI with impersonation can incur significant complication and requires careful design choices.

For information about how to encrypt and decrypt data in a Windows Phone application, see How to: Encrypt Data in a Windows Phone Application.

TopicLocation
How to: Use Data Protection.NET Framework: Security
How to: Use Data Protection.NET Framework: Security

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.