SQL Server
SQL Server
Set the JWS Payload from BinData
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.SetPayloadBd, which sets the payload to be signed from the binary bytes in a BinData.
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 from the binary bytes in a BinData.
DECLARE @bdPayload int
EXEC @hr = sp_OACreate 'Chilkat.BinData', @bdPayload OUT
EXEC sp_OAMethod @bdPayload, 'AppendString', @success OUT, 'Binary content to sign.', 'utf-8'
EXEC sp_OAMethod @jws, 'SetPayloadBd', @success OUT, @bdPayload
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @jws, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @jws
EXEC @hr = sp_OADestroy @bdPayload
RETURN
END
PRINT 'Payload set.'
EXEC @hr = sp_OADestroy @jws
EXEC @hr = sp_OADestroy @bdPayload
END
GO