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 objektu ApplicationName, PrimaryPurposea SpecificPurposes vlastnosti.

Příklady

Následující příklad ukazuje, jak použít metodu GetHashedPurpose hash vlastnosti úč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ý účel. Úplným účelem je zřetězení všech vlastností PrimaryPurpose a SpecificPurposes vlastností. Každá ze tří částí má před sebou délku, aby byla hodnota hash obrácena.

Platí pro