NServiceBus.RijndaelEncryptionService.DecryptUsingKeyIdentifier C# (CSharp) Method

DecryptUsingKeyIdentifier() private method

private DecryptUsingKeyIdentifier ( NServiceBus.EncryptedValue encryptedValue, string keyIdentifier ) : string
encryptedValue NServiceBus.EncryptedValue
keyIdentifier string
return string
        string DecryptUsingKeyIdentifier(EncryptedValue encryptedValue, string keyIdentifier)
        {
            byte[] decryptionKey;

            if (!keys.TryGetValue(keyIdentifier, out decryptionKey))
            {
                throw new InvalidOperationException($"Decryption key not available for key identifier '{keyIdentifier}'. Add this key to the rijndael encryption service configuration. Key identifiers are case sensitive.");
            }

            try
            {
                return Decrypt(encryptedValue, decryptionKey);
            }
            catch (CryptographicException ex)
            {
                throw new InvalidOperationException("Unable to decrypt property using configured decryption key specified in key identifier header.", ex);
            }
        }