Share via


DataProtector.GetHashedPurpose Methode

Definition

Erstellt einen Hash der Eigenschaftswerte, die vom Konstruktor angegeben sind.

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()

Gibt zurück

Byte[]

Ein Bytearray, das den Hash des ApplicationName, PrimaryPurpose und der SpecificPurposes-Eigenschaften enthalten.

Beispiele

Im folgenden Beispiel wird gezeigt, wie die GetHashedPurpose -Methode verwendet wird, um die Zweckeigenschaften für die Verwendung als zusätzliche Entropie zu hashen. Es ist Teil eines größeren Codebeispiels für die DataProtector -Klasse.

// 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

Hinweise

GetHashedPurpose berechnet den Hash des Anwendungsnamens und den vollständigen Zweck. Der vollständige Zweck ist eine Verkettung aller PrimaryPurpose Eigenschaften und SpecificPurposes . Jedem der drei Teile wird seine Länge vorangestellt, sodass der Hash umgekehrt werden kann.

Gilt für: