SQL Server
SQL Server
Base64url Encoding
See more Encryption Examples
Base64url encoding is identical to base64 encoding except it uses non-reserved URL characters (e.g. '–' is used instead of '+', and '_' is used instead of '/') and it omits the padding characters.Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @success int
SELECT @success = 0
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @pkey int
EXEC @hr = sp_OACreate 'Chilkat.PrivateKey', @pkey OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @rsa int
EXEC @hr = sp_OACreate 'Chilkat.Rsa', @rsa OUT
EXEC sp_OAMethod @rsa, 'GenKey', @success OUT, 1024, @pkey
EXEC sp_OAMethod @rsa, 'UsePrivateKey', @success OUT, @pkey
DECLARE @strData nvarchar(4000)
SELECT @strData = 'This is the string to be signed.'
-- Get the signature in base64url
EXEC sp_OASetProperty @rsa, 'EncodingMode', 'base64url'
DECLARE @strSig nvarchar(4000)
EXEC sp_OAMethod @rsa, 'SignStringENC', @strSig OUT, @strData, 'sha256'
PRINT @strSig
EXEC @hr = sp_OADestroy @pkey
EXEC @hr = sp_OADestroy @rsa
END
GO