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
| Feature | Description |
|---|---|
| Standard HMAC | Implemented according to RFC 2104 standard |
| Dual Algorithm Support | HMAC-SHA1, HMAC-SHA256 |
| Flexible Keys | Supports keys in string, byte array, Hex, Base64 formats |
| Chainable API | Fluent API design with method chaining |
| Multiple Outputs | Supports Hex, Base64, byte array output |
| Auto Key Processing | Automatic key length handling (auto-hash if exceeds block size) |
🚀 Quick Start
Create Instance
vb
Dim Hmac As New cCryptoHMACSimple Computation
vb
' Compute HMAC (default SHA256)
Dim result As String
result = Hmac.Compute("data to sign", "secret-key")
Debug.Print resultChainable 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
| Algorithm | Enum Value | Block Size | Description |
|---|---|---|---|
| HMAC-SHA1 | HMAC_ALG_SHA1 | 64 bytes | Good compatibility |
| HMAC-SHA256 | HMAC_ALG_SHA256 | 64 bytes | High security (recommended) |
🔐 HMAC Use Cases
HMAC is mainly used for:
- API Request Signing - Verify request integrity and identity
- Message Authentication - Ensure message has not been tampered with
- Data Integrity Verification - Integrity verification with keys
- JWT Signing - Signature part of JSON Web Tokens
🔗 Related Documentation
- methods.md - Methods detailed reference
Last Updated: 2026-05-17