DataProtector.GetHashedPurpose Méthode

Définition

Crée un hachage des valeurs de propriétés 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

Byte[]

Un tableau d'octets qui contiennent le hachage des propriétés de ApplicationName, de PrimaryPurpose, et de SpecificPurposes.

Exemples

L’exemple suivant montre comment utiliser la GetHashedPurpose méthode pour hacher les propriétés d’objectif à utiliser en tant qu’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 PrimaryPurpose propriétés et SpecificPurposes . Chacune des trois parties est préfacée avec sa longueur afin que le hachage puisse être inversé.

S’applique à