Skip to content

Latest commit

 

History

History
171 lines (149 loc) · 5.11 KB

File metadata and controls

171 lines (149 loc) · 5.11 KB
title Cryptographic Functions (Transact-SQL)
description Cryptographic Functions (Transact-SQL)
author VanMSFT
ms.author vanto
ms.date 07/24/2017
ms.service sql
ms.subservice t-sql
ms.topic reference
ms.custom
ignite-2025
helpviewer_keywords
functions [SQL Server], cryptographic
crypto functions
cryptography [SQL Server], functions
decryption [SQL Server], functions
security functions
encryption [SQL Server], functions
dev_langs
TSQL
monikerRange =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric-sqldb

Cryptographic functions (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance FabricSQLDB]

These functions support digital signing, digital signature validation, encryption, and decryption.

Symmetric encryption and decryption

:::row::: :::column::: ENCRYPTBYKEY :::column-end::: :::column::: DECRYPTBYKEY :::column-end::: :::row-end::: :::row::: :::column::: ENCRYPTBYPASSPHRASE :::column-end::: :::column::: DECRYPTBYPASSPHRASE :::column-end::: :::row-end::: :::row::: :::column::: KEY_ID :::column-end::: :::column::: KEY_GUID :::column-end::: :::row-end::: :::row::: :::column::: DECRYPTBYKEYAUTOASYMKEY :::column-end::: :::column::: KEY_NAME :::column-end::: :::row-end::: :::row::: :::column::: SYMKEYPROPERTY :::column-end::: :::column::: :::column-end::: :::row-end:::

 

Asymmetric encryption and decryption

:::row::: :::column::: ENCRYPTBYASYMKEY :::column-end::: :::column::: DECRYPTBYASYMKEY :::column-end::: :::row-end::: :::row::: :::column::: ENCRYPTBYCERT :::column-end::: :::column::: DECRYPTBYCERT :::column-end::: :::row-end::: :::row::: :::column::: ASYMKEYPROPERTY :::column-end::: :::column::: ASYMKEY_ID :::column-end::: :::row-end:::

 

Signing and signature verification

:::row::: :::column::: SIGNBYASYMKEY :::column-end::: :::column::: VERIFYSIGNEDBYASYMKEY :::column-end::: :::row-end::: :::row::: :::column::: SIGNBYCERT :::column-end::: :::column::: VERIFYSIGNEDBYCERT :::column-end::: :::row-end::: :::row::: :::column::: IS_OBJECTSIGNED :::column-end::: :::column::: :::column-end::: :::row-end:::

 

Symmetric decryption, with automatic key handling

:::row::: :::column::: DecryptByKeyAutoCert :::column-end::: :::row-end:::

 

Encryption hashing

:::row::: :::column::: HASHBYTES :::column-end::: :::row-end:::

 

Certificate copying

:::row::: :::column::: CERTENCODED (Transact-SQL) :::column-end::: :::column::: CERTPRIVATEKEY (Transact-SQL) :::column-end::: :::row-end:::

 

See also

Functions
Encryption Hierarchy
Permissions Hierarchy (Database Engine)
CREATE CERTIFICATE (Transact-SQL)
CREATE SYMMETRIC KEY (Transact-SQL)
CREATE ASYMMETRIC KEY (Transact-SQL)
Security Catalog Views (Transact-SQL)