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