Back to product page

Digest method


Digests the contents of the Blob.

Type

None

Syntax

  • Basic
object.Digest Data, OutBlob
The Digest(object,Data,OutBlob) syntax has these parts:
objectAn expression evaluating to an object of type wodCrypt.
DataRequired. A Blob object. Contains data to be digested.
OutBlobRequired. A Blob object. Fixed-size digest result.

Remarks

The Digest method will take an existing Data Blob, and calculate its hash/digest value. The result will be stored to OutBlob initialized by your program. The resulting Blob will *always* contain 16/20/32/48/64 bytes, depending on whether MD5, SHA1, SHA256, SHA384, SHA512, CRC16 or CRC32 algorithm type is used.

To provide some background theory, a hash/digest function is a transformation that takes a variable size input, and returns a fixed size byte array/string. A hash function is said to be one-way, because it is hard to invert it - meaning it's almost impossible to determine the original data from it's hashed equivalent.

Hash functions are usually used when both parties in a conversation need to prove they both have same data (but don't want to reveal it to other side, just in case...). They both calculate their digest and, if they match, then both parties have same data. If it does not match then the other party cannot derive the original data given the hash value alone.

Code sample

  • Basic

Platforms

Windows