DataProtector.GetHashedPurpose Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Oluşturucu tarafından belirtilen özellik değerlerinin karması oluşturur.
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()
Döndürülenler
, ApplicationNameve PrimaryPurpose özelliklerinin karması SpecificPurposesiçeren bayt dizisi.
Örnekler
Aşağıdaki örnekte, ek entropi olarak kullanılmak üzere amaç özelliklerini karma olarak kullanmak için yönteminin nasıl GetHashedPurpose kullanılacağı gösterilmektedir. Sınıfı için daha büyük bir kod örneğinin DataProtector bir parçasıdır.
// 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
Açıklamalar
GetHashedPurpose uygulama adının karması ile tam amacı hesaplar. Amacın tamamı ve PrimaryPurpose özelliklerinin birleştirilmiş SpecificPurposes olmasıdır. Üç bölümün her biri, uzunluğuyla önsöze alınır, bu nedenle karma ters çevrilebilir.