ProtectedMemory.Unprotect(Byte[], MemoryProtectionScope) 메서드

정의

Protect(Byte[], MemoryProtectionScope) 메서드를 사용하여 보호된 메모리에 있는 데이터의 보호를 해제합니다.

public:
 static void Unprotect(cli::array <System::Byte> ^ encryptedData, System::Security::Cryptography::MemoryProtectionScope scope);
public static void Unprotect (byte[] encryptedData, System.Security.Cryptography.MemoryProtectionScope scope);
static member Unprotect : byte[] * System.Security.Cryptography.MemoryProtectionScope -> unit
Public Shared Sub Unprotect (encryptedData As Byte(), scope As MemoryProtectionScope)

매개 변수

encryptedData
Byte[]

보호를 해제할 메모리에 있는 바이트 배열입니다.

scope
MemoryProtectionScope

메모리 보호의 범위를 지정하는 열거형 값 중 하나입니다.

예외

운영 체제에서 이 메서드를 지원하지 않는 경우. 이 메서드는 Windows 2000 이상의 운영 체제에서만 사용할 수 있습니다.

encryptedData이(가) null인 경우

encryptedData가 비어 있는 경우

또는 이 호출이 구현되지 않은 경우

또는 NTSTATUS에 오류가 있는 경우

예제

다음 예제에서는 데이터 보호를 사용 하는 방법을 보여 줍니다.

#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;

int main()
{
   
   // Create the original data to be encrypted (The data length should be a multiple of 16).
   array<Byte>^secret = {1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4};
   
   // Encrypt the data in memory. The result is stored in the same array as the original data.
   ProtectedMemory::Protect( secret, MemoryProtectionScope::SameLogon );
   
   // Decrypt the data in memory and store in the original array.
   ProtectedMemory::Unprotect( secret, MemoryProtectionScope::SameLogon );
}
using System;
using System.Security.Cryptography;

public class MemoryProtectionSample
{

    public static void Main()
    {
        // Create the original data to be encrypted (The data length should be a multiple of 16).
        byte [] secret = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 };

        // Encrypt the data in memory. The result is stored in the same array as the original data.
        ProtectedMemory.Protect( secret, MemoryProtectionScope.SameLogon );

        // Decrypt the data in memory and store in the original array.
        ProtectedMemory.Unprotect( secret, MemoryProtectionScope.SameLogon );
    }
}
Imports System.Security.Cryptography

Public Class MemoryProtectionSample

    Public Shared Sub Main()
        ' Create the original data to be encrypted (The data length should be a multiple of 16).
        Dim secret As Byte() = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}

        ' Encrypt the data in memory. The result is stored in the same array as the original data.
        ProtectedMemory.Protect(secret, MemoryProtectionScope.SameLogon)

        ' Decrypt the data in memory and store in the original array.
        ProtectedMemory.Unprotect(secret, MemoryProtectionScope.SameLogon)

    End Sub
End Class

설명

이 메서드를 사용 하 여 암호화 된 메모리의 데이터 보호를 해제할 수는 Protect 메서드.

이 메서드에 대 한 지원은 Windows XP 및 이후 운영 체제에서 사용할 수 있습니다.

적용 대상