DataProtector.GetHashedPurpose DataProtector.GetHashedPurpose DataProtector.GetHashedPurpose DataProtector.GetHashedPurpose Method

Définition

Crée un hachage des valeurs de propriétés spécifiées par le constructeur.Creates a hash of the property values specified by the constructor.

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

Byte[]

Un tableau d'octets qui contiennent le hachage des propriétés de ApplicationName, de PrimaryPurpose, et de SpecificPurposes.An array of bytes that contain the hash of the ApplicationName, PrimaryPurpose, and SpecificPurposes properties.

Exemples

L’exemple suivant montre comment utiliser la GetHashedPurpose méthode pour hacher les propriétés d’objet à utiliser comme entropie supplémentaire.The following example shows how to use the GetHashedPurpose method to hash the purpose properties for use as extra entropy. Elle fait partie d’un exemple de code plus large DataProtector pour la classe.It is part of a larger code example for the DataProtector class.

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

GetHashedPurposecalcule le hachage du nom de l’application et de l’objet complet.GetHashedPurpose computes the hash of the application name and the full purpose. L’objectif complet est une concaténation de toutes PrimaryPurpose les propriétés et. SpecificPurposesThe full purpose is a concatenation of all the PrimaryPurpose and SpecificPurposes properties. Chacune des trois parties est précédée de sa longueur, de sorte que le hachage peut être inversé.Each of the three parts is prefaced with its length so the hash can be reversed.

S’applique à