다음을 통해 공유


CryptographicEngine.Decrypt(CryptographicKey, IBuffer, IBuffer) 메서드

정의

대칭 또는 비대칭 알고리즘을 사용하여 이전에 암호화된 콘텐츠의 암호를 해독합니다.

public:
 static IBuffer ^ Decrypt(CryptographicKey ^ key, IBuffer ^ data, IBuffer ^ iv);
 static IBuffer Decrypt(CryptographicKey const& key, IBuffer const& data, IBuffer const& iv);
public static IBuffer Decrypt(CryptographicKey key, IBuffer data, IBuffer iv);
function decrypt(key, data, iv)
Public Shared Function Decrypt (key As CryptographicKey, data As IBuffer, iv As IBuffer) As IBuffer

매개 변수

key
CryptographicKey

암호 해독에 사용할 암호화 키입니다. 비대칭 또는 대칭 키일 수 있습니다. 자세한 내용은 AsymmetricKeyAlgorithmProviderSymmetricKeyAlgorithmProvider를 참조하세요.

data
IBuffer

암호화된 데이터를 포함하는 버퍼입니다.

iv
IBuffer

초기화 벡터를 포함하는 버퍼입니다. IV(초기화 벡터)를 사용하여 데이터를 암호화한 경우 동일한 IV를 사용하여 데이터의 암호를 해독해야 합니다. 자세한 내용은 암호화를 참조 하세요.

반환

암호를 해독한 데이터입니다.

예제

public void SampleCipherDecryption(
    String strAlgName,
    IBuffer buffEncrypt,
    IBuffer iv,
    BinaryStringEncoding encoding,
    CryptographicKey key)
{
    // Declare a buffer to contain the decrypted data.
    IBuffer buffDecrypted;

    // Open an symmetric algorithm provider for the specified algorithm. 
    SymmetricKeyAlgorithmProvider objAlg = SymmetricKeyAlgorithmProvider.OpenAlgorithm(strAlgName);

    // The input key must be securely shared between the sender of the encrypted message
    // and the recipient. The initialization vector must also be shared but does not
    // need to be shared in a secure manner. If the sender encodes a message string 
    // to a buffer, the binary encoding method must also be shared with the recipient.
    buffDecrypted = CryptographicEngine.Decrypt(key, buffEncrypt, iv);

    // Convert the decrypted buffer to a string (for display). If the sender created the
    // original message buffer from a string, the sender must tell the recipient what 
    // BinaryStringEncoding value was used. Here, BinaryStringEncoding.Utf8 is used to
    // convert the message to a buffer before encryption and to convert the decrypted
    // buffer back to the original plaintext.
    String strDecrypted = CryptographicBuffer.ConvertBinaryToString(encoding, buffDecrypted);
}

설명

매개 변수는 PersistedKeyProvider 클래스를 사용하여 인증서에서 가져온 지속형 키일 수 있습니다.

키가 지속형 키이고 암호 해독 작업에 UI가 필요하거나 시간이 오래 걸리는 경우 대신 DecryptAsync 메서드를 사용합니다. 예를 들어 강력하게 보호되는 키를 사용하여 암호를 해독하는 경우 UI가 필요합니다. 지속형 키가 사용되고 UI가 필요한 경우 Decrypt 메서드가 실패하므로 DecryptAsync 메서드를 사용합니다.

적용 대상

추가 정보