CryptoSys API Library Manual

SHA2_StringHexHash

SHA2_StringHexHash creates a SHA-256 message digest in hexadecimal format from a message of String type.

VB6/VBA Syntax

Public Declare Function SHA2_StringHexHash Lib "diCryptoSys.dll" (ByVal strDigest As String, ByVal strMessage As String) As Long

nRet = SHA2_StringHexHash(strDigest, strMessage)

Parameters

strDigest
[out] String to receive message digest.
strMessage
[in] String containing the message to be hashed.

C/C++ Syntax

long _stdcall SHA2_StringHexHash(char *strDigest, const char *strMessage);

Returns (VB6/C)

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

.NET Equivalent

Sha256.HexHash Method (String)

COM/ASP Equivalent

sha256.StringHexHash
Public Function StringHexHash(ByVal strData As String) As String

See sha256.StringHexHash.

Remarks

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

Example

    Dim nRet As Long
    Dim strDigest As String
    ' Set strDigest to be 64 chars
    strDigest = String(64, " ")
    nRet = SHA2_StringHexHash(strDigest, "abc")
    Debug.Print strDigest

    nRet = SHA2_StringHexHash(strDigest, _
        "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
    Debug.Print strDigest

This should result in output as follows:

ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1

See Also

SHA2_FileHexHash SHA2_BytesHexHash

[Contents] [Index]

[HOME]   [NEXT: TDEA_B64Mode...]

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