DataProtector.GetHashedPurpose 메서드

정의

생성자로 지정된 속성 값의 해시를 만듭니다.

protected:
 virtual cli::array <System::Byte> ^ GetHashedPurpose();
protected virtual byte[] GetHashedPurpose ();
abstract member GetHashedPurpose : unit -> byte[]
override this.GetHashedPurpose : unit -> byte[]
Protected Overridable Function GetHashedPurpose () As Byte()

반환

Byte[]

ApplicationName, PrimaryPurposeSpecificPurposes 속성의 해시를 포함하는 바이트의 배열입니다.

예제

다음 예제에서는 메서드를 사용하여 GetHashedPurpose 추가 엔트로피로 사용할 용도 속성을 해시하는 방법을 보여 있습니다. 클래스에 대한 더 큰 코드 예제의 DataProtector 일부입니다.

// To allow a service to hand out instances of a DataProtector we demand unrestricted DataProtectionPermission
// in the constructor, but Assert the permission when ProviderProtect is called.  This is similar to FileStream
// where access is checked at time of creation, not time of use.
[SecuritySafeCritical]
[DataProtectionPermission(SecurityAction.Assert, ProtectData = true)]
protected override byte[] ProviderProtect(byte[] userData)
{
    // Delegate to ProtectedData
    return ProtectedData.Protect(userData, GetHashedPurpose(), Scope);
}
' To allow a service to hand out instances of a DataProtector we demand unrestricted DataProtectionPermission 
' in the constructor, but Assert the permission when ProviderProtect is called.  This is similar to FileStream
' where access is checked at time of creation, not time of use.
<SecuritySafeCritical(), DataProtectionPermission(SecurityAction.Assert, ProtectData:=True)> _
Protected Overrides Function ProviderProtect(ByVal userData() As Byte) As Byte()
    ' Delegate to ProtectedData
    Return ProtectedData.Protect(userData, GetHashedPurpose(), Scope)

End Function 'ProviderProtect

설명

GetHashedPurpose 애플리케이션 이름 및 전체 목적은의 해시를 계산 합니다. 전체 목적은 모든 PrimaryPurposeSpecificPurposes 속성의 연결입니다. 세 부분의 각각 앞에 길이가 있으므로 해시를 되돌릴 수 있습니다.

적용 대상