DataProtector.GetHashedPurpose Metoda

Definicja

Tworzy skrót wartości właściwości określonych przez konstruktora.

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

Zwraca

Byte[]

Tablica bajtów zawierająca skrót ApplicationNamewłaściwości , PrimaryPurposei SpecificPurposes .

Przykłady

W poniższym przykładzie pokazano, jak używać GetHashedPurpose metody do mieszania właściwości przeznaczenia do użycia jako dodatkowej entropii. Jest to część większego przykładu DataProtector kodu dla klasy.

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

Uwagi

GetHashedPurpose oblicza skrót nazwy aplikacji i pełny cel. Pełny cel to połączenie wszystkich PrimaryPurpose właściwości i SpecificPurposes . Każda z trzech części jest poprzedzona jego długością, dzięki czemu skrót można odwrócić.

Dotyczy