通过


DpapiDataProtector 类

定义

提供简单的数据保护方法。

public ref class DpapiDataProtector sealed : System::Security::Cryptography::DataProtector
public sealed class DpapiDataProtector : System.Security.Cryptography.DataProtector
type DpapiDataProtector = class
    inherit DataProtector
Public NotInheritable Class DpapiDataProtector
Inherits DataProtector
继承
DpapiDataProtector

注解

DpapiDataProtector 类提供了使用类保护数据的 ProtectedData 结构化方法。 类构造函数具有类似于密码以标识受保护数据的目的参数。 所有三个参数都经过哈希处理,并作为加密数据字符串的一部分包含在内。 必须知道用于取消保护数据的目的参数。 ProtectedData.Protect调用以加密数据的方法具有一个optionalEntropy参数,用于添加限定信息以更安全地加密数据。 用途参数的哈希用于可选 entropy。 由于不需要密钥来解密数据,因此仔细选择目的数据会增加数据保护的另一个安全级别。

如果使用 Scope 此设置 CurrentUser,则只有具有与加密数据的用户匹配的登录凭据的用户才能解密数据。 此外,解密通常只能在加密数据的计算机上完成。 加密数据的 Windows 函数会创建会话密钥来执行加密。 在解密数据时,会话密钥将再次派生。

如果在保护数据时使用 Scope 设置 LocalMachine ,并且不仔细识别目的参数,则该计算机上的任何其他知道目的的应用程序都可以访问和取消保护数据。

构造函数

名称 说明
DpapiDataProtector(String, String, String[])

使用指定的应用程序名称、主要用途和特定用途创建类的新实例 DpapiDataProtector

属性

名称 说明
ApplicationName

获取应用程序的名称。

(继承自 DataProtector)
PrependHashedPurposeToPlaintext

指定是否在加密之前将哈希追加到文本数组。

(继承自 DataProtector)
PrimaryPurpose

获取受保护数据的主要用途。

(继承自 DataProtector)
Scope

获取或设置数据保护的范围。

SpecificPurposes

获取受保护数据的特定用途。

(继承自 DataProtector)

方法

名称 说明
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetHashedPurpose()

创建构造函数指定的属性值的哈希。

(继承自 DataProtector)
GetType()

获取当前实例的 Type

(继承自 Object)
IsReprotectRequired(Byte[])

确定数据是否必须重新加密。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
Protect(Byte[])

保护指定的用户数据。

(继承自 DataProtector)
ProviderProtect(Byte[])

指定基类中该方法调用回的派生类 Protect(Byte[]) 中的委托方法。

(继承自 DataProtector)
ProviderUnprotect(Byte[])

指定基类中该方法调用回的派生类 Unprotect(Byte[]) 中的委托方法。

(继承自 DataProtector)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
Unprotect(Byte[])

取消保护指定的受保护数据。

(继承自 DataProtector)

适用于