Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

SignByAsymKey (Transact-SQL)

Signs plaintext with an asymmetric key


SignByAsymKey( Asym_Key_ID , @plaintext [ , 'password' ] )

Asym_Key_ID

The ID of an asymmetric key in the current database. int.

@plaintext

A variable of type nvarchar, char, varchar, or nchar containing data that will be signed with the asymmetric key.

password

Password with which the private key is protected. nvarchar(128).

varbinary with a maximum size of 8,000 bytes.

Requires CONTROL permission on the asymmetric key.

A. Store data with its signature, generated with asymmetric key .

The following example creates a table, SignedData04, in which to store plaintext and its signature. It next inserts a record in the table, signed with asymmetric key PrimeKey, which is first decrypted with password 'pGFD4bb925DGvbd2439587y'.

-- Create a table in which to store the data
CREATE TABLE [SignedData04]( Description nvarchar(max), Data nvarchar(max), DataSignature varbinary(8000) );
GO
-- Store data together with its signature
DECLARE @clear_text_data nvarchar(max);
set @clear_text_data = N'Important numbers 2, 3, 5, 7, 11, 13, 17, 
      19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
      83, 89, 97';
INSERT INTO [SignedData04] 
    VALUES( N'data encrypted by asymmetric key ''PrimeKey''',
    @clear_text_data, SignByAsymKey( AsymKey_Id( 'PrimeKey' ),
    @clear_text_data, N'pGFD4bb925DGvbd2439587y' ));
GO

Community Additions

ADD
Show:
© 2015 Microsoft