Decrypts data with an asymmetric key.
Is the ID of an asymmetric key in the database. int.
Is a string of data that has been encrypted with the asymmetric key.
Is a variable of type varbinary that contains data that has been encrypted with the asymmetric key.
Is the password that was used to encrypt the asymmetric key in the database.
The following example decrypts ciphertext that was encrypted with asymmetric key
JanainaAsymKey02, which was stored in
AdventureWorks.ProtectedData04. The returned data is decrypted using asymmetric key
JanainaAsymKey02, which has been decrypted with password
pGFD4bb925DGvbd2439587y. The plaintext is converted to type nvarchar.
SELECT CONVERT(nvarchar(max), DecryptByAsymKey( AsymKey_Id('JanainaAsymKey02'), ProtectedData, N'pGFD4bb925DGvbd2439587y' )) AS DecryptedData FROM [AdventureWorks].[Sales].[ProtectedData04] WHERE Description = N'encrypted by asym key''JanainaAsymKey02'''; GO