Skip to content

HMAC Component Overview

📖 Introduction

cCryptoHMAC is a Windows CryptoAPI-based HMAC (Hash-based Message Authentication Code) implementation that supports HMAC-SHA1 and HMAC-SHA256 algorithms.

✨ Key Features

FeatureDescription
Standard HMACImplemented according to RFC 2104 standard
Dual Algorithm SupportHMAC-SHA1, HMAC-SHA256
Flexible KeysSupports keys in string, byte array, Hex, Base64 formats
Chainable APIFluent API design with method chaining
Multiple OutputsSupports Hex, Base64, byte array output
Auto Key ProcessingAutomatic key length handling (auto-hash if exceeds block size)

🚀 Quick Start

Create Instance

vb
Dim Hmac As New cCryptoHMAC

Simple Computation

vb
' Compute HMAC (default SHA256)
Dim result As String
result = Hmac.Compute("data to sign", "secret-key")
Debug.Print result

Chainable Call

vb
' Use chainable call
Dim result As String
result = Hmac.Mode(HMAC_ALG_SHA256) _
            .Secret("secret-key") _
            .DataString("data to sign") _
            .ReturnHex()

📋 Supported Algorithms

AlgorithmEnum ValueBlock SizeDescription
HMAC-SHA1HMAC_ALG_SHA164 bytesGood compatibility
HMAC-SHA256HMAC_ALG_SHA25664 bytesHigh security (recommended)

🔐 HMAC Use Cases

HMAC is mainly used for:

  1. API Request Signing - Verify request integrity and identity
  2. Message Authentication - Ensure message has not been tampered with
  3. Data Integrity Verification - Integrity verification with keys
  4. JWT Signing - Signature part of JSON Web Tokens

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation