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, PrimaryPurpose и SpecificPurposes.

Примеры

В следующем примере показано, как использовать 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 вычисляет хэш имени приложения и полное назначение. Полное назначение — объединение всех PrimaryPurpose свойств и SpecificPurposes . Каждая из трех частей предваряется своей длиной, поэтому хэш можно изменить.

Применяется к