SQL Server Stored Procedure Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
DKIM / DomainKey
FTP
HTML Conversion
HTTP
MHT
MIME
NTLM
RSA
Diffie-Hellman
DSA
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
String
Tar
Upload
XML
XMP
Zip

Amazon S3
Bz2
CSV
FileAccess
Byte Array
RSS
Atom
Self-Extractor

HMAC SHA-1 to Match RFC 2022 Test Vectors

Demonstrates using Chilkat in SQL Server to computer HMAC SHA-1 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 @sTmp0 nvarchar(4000)
    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, 'Anything for 30-day trial.'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @crypt, 'LastErrorText', @sTmp0 OUT

        PRINT @sTmp0
        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', 'sha-1'

    DECLARE @mac nvarchar(4000)

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

    PRINT @mac

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

    PRINT @mac
END
GO

 

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