Bagikan melalui


DataProtector.GetHashedPurpose Metode

Definisi

Membuat hash nilai properti yang ditentukan oleh konstruktor.

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

Mengembalikan

Byte[]

Array byte yang berisi hash ApplicationNameproperti , , PrimaryPurposedan SpecificPurposes .

Contoh

Contoh berikut menunjukkan cara menggunakan GetHashedPurpose metode untuk hash properti tujuan untuk digunakan sebagai entropi tambahan. Ini adalah bagian dari contoh kode yang lebih besar untuk DataProtector kelas .

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

Keterangan

GetHashedPurpose menghitung hash nama aplikasi dan tujuan penuh. Tujuan lengkapnya adalah perangkaian semua PrimaryPurpose properti dan SpecificPurposes . Masing-masing dari tiga bagian diawali dengan panjangnya sehingga hash dapat dibalik.

Berlaku untuk