CryptoSys API Library Manual

SHA2_BytesHexHash

SHA2_BytesHexHash creates a SHA-256 message digest in hexadecimal format from a message in Byte array format.

VB6/VBA Syntax

Public Declare Function SHA2_BytesHexHash Lib "diCryptoSys.dll" (ByVal strDigest As String, ByRef abData As Byte, ByVal nDataLen As Long) As Long

nRet = SHA2_BytesHexHash(strDigest, abData(0), nDataLen)

Parameters

strDigest
[out] String to receive message digest.
abData
[in] Byte array containing the message to be hashed.
nDataLen
[in] Long containing number of bytes in the array.

C/C++ Syntax

long _stdcall SHA2_BytesHexHash(char *strDigest, const unsigned char *bytes, long len);

Returns (VB6/C)

Long: If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Sha256.HexHash Method (Byte[])

COM/ASP Equivalent

sha256.HexHexHash
Public Function HexHexHash(ByVal strHexData As String) As String

See sha256.HexHexHash.

Remarks

strDigest must be at least 64 (API_MAX_SHA2_CHARS) characters long (65 in a C program). Note the (0) in abData(0).

Example

    Dim nRet As Long
    Dim abData(2) As Byte   ' Create 3-byte array (NB zero-based)
    ' Alternative way of making sure string is 64 chars long
    Dim strDigest As String * 64

    ' Setup byte array with "abc"
    abData(0) = Asc("a")
    abData(1) = Asc("b")
    abData(2) = Asc("c")

    nRet = SHA2_BytesHexHash(strDigest, abData(0), 3)
    Debug.Print nRet; strDigest

This should result in output as follows:

 0 ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

See Also

SHA2_StringHexHash SHA2_FileHexHash

[Contents] [Index]

[HOME]   [NEXT: SHA2_FileHexHash...]

Copyright © 2001-9 D.I. Management Services Pty Ltd. All rights reserved.