Share via


DataProtection Class

Represents the ability to encrypt and decrypt strings using the Windows Data Protection API (DPAPI).

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Data.DataProtection

Namespace:  Microsoft.VisualStudio.Data
Assembly:  Microsoft.VisualStudio.Data (in Microsoft.VisualStudio.Data.dll)

Syntax

'Declaration
Public NotInheritable Class DataProtection
public sealed class DataProtection
public ref class DataProtection sealed
[<Sealed>]
type DataProtection =  class end
public final class DataProtection

The DataProtection type exposes the following members.

Methods

  Name Description
Public methodStatic member DecryptString Decrypts a specified string.
Public methodStatic member EncryptString Encrypts a specified string.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

When working with data connection strings, Visual Studio tries to keep encrypted data in its encrypted state. In general, the DDEX API represents connection strings as a "display" connection string, which contains no sensitive information, and as an "encrypted" connection string, which is more complete. DDEX uses the methods on this class to encrypt or decrypt these strings.

The encryption algorithm used depends on the current user and machine, and as such a string encrypted using the EncryptString method can only be decrypted by calling the DecryptString method when running as the same user on the same machine.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Data Namespace

DataConnection

DPAPIProtectedConfigurationProvider