DataProtector.GetHashedPurpose Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Crée un hachage des valeurs de propriété spécifiées par le constructeur.
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()
Retours
Tableau d’octets qui contiennent le hachage du ApplicationName, PrimaryPurposeet SpecificPurposes des propriétés.
Exemples
L’exemple suivant montre comment utiliser la GetHashedPurpose méthode pour hacher les propriétés d’usage à utiliser comme entropie supplémentaire. Il fait partie d’un exemple de code plus grand pour la DataProtector classe.
// 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
Remarques
GetHashedPurpose calcule le hachage du nom de l’application et l’objectif complet. L’objectif complet est une concaténation de toutes les propriétés et PrimaryPurpose propriétésSpecificPurposes. Chacune des trois parties est précédée de sa longueur afin que le hachage puisse être inversé.