DataProtector.GetHashedPurpose Metoda

Definice

Vytvoří hodnotu hash hodnot vlastností určených konstruktorem.

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

Návraty

Byte[]

Pole bajtů, které obsahují hodnotu hash ApplicationNamevlastností , PrimaryPurposea SpecificPurposes .

Příklady

Následující příklad ukazuje, jak použít metodu GetHashedPurpose k zatřiďování vlastností účelu pro použití jako extra entropie. Je součástí většího příkladu DataProtector kódu pro třídu.

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

Poznámky

GetHashedPurpose Vypočítá hodnotu hash názvu aplikace a úplného účelu. Úplným účelem je zřetězení všech PrimaryPurpose vlastností a SpecificPurposes . Každá ze tří částí má před sebou svou délku, aby bylo možné hodnotu hash převrátit.

Platí pro