SQL Server
SQL Server
Set the JWS Payload
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.SetPayload, which sets the content to be signed. The charset converts the text to bytes, and a flag controls whether a byte-order mark is included.
Background. JWS (JSON Web Signature) integrity-protects a payload with a signature or MAC. The header
alg names the algorithm; this example uses HMAC-SHA256 (HS256) with a symmetric MAC key.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @jws int
EXEC @hr = sp_OACreate 'Chilkat.Jws', @jws OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Set the payload (the content to be signed). The 2nd argument is the charset used to convert the
-- text to bytes, and the 3rd controls whether a byte-order mark is included.
DECLARE @bIncludeBom int
SELECT @bIncludeBom = 0
EXEC sp_OAMethod @jws, 'SetPayload', @success OUT, 'This is the content to sign.', 'utf-8', @bIncludeBom
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @jws, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @jws
RETURN
END
PRINT 'Payload set.'
EXEC @hr = sp_OADestroy @jws
END
GO