DataProtector.ProviderProtect(Byte[]) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Especifica o método delegado na classe derivada para o qual o Protect(Byte[]) método na classe base chama de volta.
protected:
abstract cli::array <System::Byte> ^ ProviderProtect(cli::array <System::Byte> ^ userData);
protected abstract byte[] ProviderProtect(byte[] userData);
abstract member ProviderProtect : byte[] -> byte[]
Protected MustOverride Function ProviderProtect (userData As Byte()) As Byte()
Parâmetros
- userData
- Byte[]
Os dados a serem encriptados.
Devoluções
Um array de bytes que contém os dados encriptados.
Exemplos
O exemplo seguinte mostra uma implementação do ProviderProtect método. Faz parte de um exemplo de código maior para a 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
ProtectedMemory.Protect(userData, Scope);
return userData;
}
' 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
ProtectedMemory.Protect(userData, Scope)
Return userData
End Function 'ProviderProtect