SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
FTP
HTML-to-XML
HTTP
MHT
MIME
RSA Encryption
Socket
Spider
String
Tar
Upload
XML
XMP
Zip

Byte Array
RSS
Atom
Self-Extractor

HMAC MD5 to Match RFC 2022 Test Vectors

Demonstrates using Chilkat in SQL Server to computer HMAC MD5 message authentication codes to match the test vectors given by RFC 2202.

Download Chilkat Crypt ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @crypt int
    EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Any string argument automatically begins the 30-day trial.
    DECLARE @success int

    EXEC sp_OAMethod @crypt, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        PRINT 'Crypt component unlock failed'
        RETURN
      END

    --  The output will be Hex, so set the EncodingMode:
    EXEC sp_OASetProperty @crypt, 'EncodingMode', 'hex'

    --  Set the hash algorithm:
    --  Choices are: md5, sha-1, sha256, sha384, sha512, md2, haval
    EXEC sp_OASetProperty @crypt, 'HashAlgorithm', 'md5'

    DECLARE @mac nvarchar(4000)

    --  Set the HMAC key:
    EXEC sp_OAMethod @crypt, 'SetHmacKeyEncoded', NULL, '0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'
    EXEC sp_OAMethod @crypt, 'HmacStringENC', @mac OUT, 'Hi There'

    PRINT @mac

    EXEC sp_OAMethod @crypt, 'SetHmacKeyEncoded', NULL, 'Jefe', 'us-ascii'
    EXEC sp_OAMethod @crypt, 'HmacStringENC', @mac OUT, 'what do ya want for nothing?'

    PRINT @mac
END
GO

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.