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

暗号化解除に使用する暗号化キー。 非対称キーまたは対称キーを指定できます。 詳細については、「 AsymmetricKeyAlgorithmProvider 」および 「SymmetricKeyAlgorithmProvider」を参照してください。

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);
}

注釈

key パラメーターには、PersistedKeyProvider クラスを使用して証明書から取得した永続化キーを指定できます。

キーが永続化されたキーであり、復号化操作に UI が必要な場合、または長い時間がかかる場合は、代わりに DecryptAsync メソッドを使用します。 たとえば、厳密に保護されているキーを使用して復号化する場合は UI が必要です。 永続化されたキーが使用され、UI が必要な場合は、Decrypt メソッドが失敗するにつれて DecryptAsync メソッドを使用します。

適用対象

こちらもご覧ください