CryptoHash Object

Overview

The CryptoHash object provides one-way hash functionality. You can use it to compute MD2, MD4, MD5 and SHA hash functions of files and text strings.

Member List

Properties


Value As CryptoBlob (Read/Write)

Specifies the effective size of an RC2 key. Applying this property to a key of any cipher other than RC2 will throw an error. Returns a CryptoBlob object containing the result of a one-way hash function.

As of Version 2.9, can be used to populate this CryptoHash object with a value. In versions prior to 2.9, this property was read-only.

Methods


Sub AddBinary(Blob As CryptoBlob)

Adds the content of a blob specified by Blob to the hash object. This function can be called multiple times before the result hash value is retrieved via the Value property.

Return Value: a CryptoBlob containing the decrypted buffer.

Usage:

Hash.AddBinary blob

Related Section: 3.4 Computing Hash Function of Files.


Sub AddFile(Path As String)

Adds the content of a file specified by Path to the hash object. This function can be called multiple times before the result hash value is retrieved via the Value property.

Usage:

Hash.AddFile "c:\myfile.txt"

Related Section: 3.4 Computing Hash Function of Files.


Sub AddText(Path As String)

Adds Text to the hash object. This function can be called multiple times before the result hash value is retrieved via the Value property.

Usage:

Hash.AddText "my text"

Related Section: 3.2 Computing Hash with AspEncrypt.


Function DeriveKey(Optional Algorithm = RC2, Optional BitSize = 0) As CryptoKey

Derives a symmetric cryptographic key from the hash. Algorithm specifies the encryption algorithm for the key being generated. BitSize specifies the key size. For the description of these arguments, see the comments to CryptoContext's GenerateKey method.

Return Value: a CryptoKey object containing the newly generated key.

Usage:

Set Key = Hash.DeriveKey

Sub Reset()

Clears the CryptoHash object so that a new hash can be computed.

Return Value: a CryptoKey object containing the newly generated key.

Usage:

Hash.Reset

Related Section: 3.2 Computing Hash with AspEncrypt.


Function Sign(KeyExchange As Boolean) As CryptoBlob

Generates a digital signature by encrypting the underlying hash value with a private key pertaining to the context used to create this hash object. If KeyExchange is True, the key-exchange key will be used. Otherwise, the singature key will be used.

Return Value: a CryptoBlob object containing signature blob.

Usage:

Set Blob = Hash.Sign( True )

Related Section: 6.3 Creating and Verifying Digital Signatures.


Function VerifySignature(Signature As CryptoBlob, Key As CryptoKey) As Boolean

Verifies the specified Signature blob by decrypting it with the specified public Key and comparing the decrypted value with the underlying hash.

Return Value: True if the signature is verified, False otherwise.

Usage:

If Hash.VerifySignature( Blob, Key ) Then ...

Related Section: 6.3 Creating and Verifying Digital Signatures.

CryptoKey CryptoMessage