DataProtector.ProviderUnprotect(Byte[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定衍生類別中的委派方法,基底類別中的 Unprotect(Byte[]) 方法會呼叫回此方法中。
protected:
abstract cli::array <System::Byte> ^ ProviderUnprotect(cli::array <System::Byte> ^ encryptedData);
protected abstract byte[] ProviderUnprotect (byte[] encryptedData);
abstract member ProviderUnprotect : byte[] -> byte[]
Protected MustOverride Function ProviderUnprotect (encryptedData As Byte()) As Byte()
參數
- encryptedData
- Byte[]
要解密的資料。
傳回
Byte[]
未加密的資料。
範例
下列範例會示範 ProviderUnprotect 方法的實作。 它是類別較大程式代碼範例的 DataProtector 一部分。
// To allow a service to hand out instances of a DataProtector we demand unrestricted DataProtectionPermission
// in the constructor, but Assert the permission when ProviderUnprotect is called.. This is similar to FileStream
// where access is checked at time of creation, not time of use.
[SecuritySafeCritical]
[DataProtectionPermission(SecurityAction.Assert, UnprotectData = true)]
protected override byte[] ProviderUnprotect(byte[] encryptedData)
{
ProtectedMemory.Unprotect(encryptedData,Scope);
return encryptedData;
}
' To allow a service to hand out instances of a DataProtector we demand unrestricted DataProtectionPermission
' in the constructor, but Assert the permission when ProviderUnprotect is called.. This is similar to FileStream
' where access is checked at time of creation, not time of use.
<SecuritySafeCritical(), DataProtectionPermission(SecurityAction.Assert, UnprotectData:=True)> _
Protected Overrides Function ProviderUnprotect(ByVal encryptedData() As Byte) As Byte()
ProtectedMemory.Unprotect(encryptedData, Scope)
Return encryptedData
End Function 'ProviderUnprotect