Skip to content

Hash Component Overview

📖 Introduction

cCryptoHash is a Windows CryptoAPI-based hash computation class that supports multiple hash algorithms including MD5, SHA1, SHA256, SHA384, and SHA512.

✨ Key Features

FeatureDescription
Multiple AlgorithmsMD5, SHA1, SHA256, SHA384, SHA512
Multiple InputsSupports strings, byte arrays, files
Multiple OutputsSupports Hex strings, Base64, byte arrays
Chainable APIFluent API design with method chaining
Auto CSP SelectionAutomatically selects appropriate cryptographic service provider
Encoding SupportSupports UTF-8 and ANSI encoding

🚀 Quick Start

Create Instance

vb
Dim Hash As New cCryptoHash

Simple Hash Computation

vb
' Compute string hash (default SHA256)
Dim hashValue As String
hashValue = Hash.ComputeHash("Hello World")
Debug.Print hashValue  ' 64-character hex string

Chainable Call

vb
' Use chainable call
Dim result As String
result = Hash.Mode(HASH_ALG_SHA256) _
            .DataString("Hello World") _
            .ReturnHex()

Compute File Hash

vb
' Compute file SHA256
Dim fileHash As String
fileHash = Hash.ComputeFileHash("C:\data.txt")

📋 Supported Algorithms

AlgorithmEnum ValueOutput LengthDescription
MD5HASH_ALG_MD5128 bit (32 hex)Not recommended for security
SHA1HASH_ALG_SHA1160 bit (40 hex)Being deprecated
SHA256HASH_ALG_SHA256256 bit (64 hex)Recommended
SHA384HASH_ALG_SHA384384 bit (96 hex)High security
SHA512HASH_ALG_SHA512512 bit (128 hex)Highest security

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation