Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
HMAC SHA-1 to Match RFC 2022 Test VectorsDemonstrates using Chilkat in SQL Server to computer HMAC SHA-1 message authentication codes to match the test vectors given by RFC 2202.
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', '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', '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.