CryptoSys API Library Manual

SHA2_StringHexHash

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

VBA/VB6 Syntax

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

nRet = SHA2_StringHexHash(strDigest, strMessage)

C/C++ Syntax

long __stdcall SHA2_StringHexHash(char *szDigest, const char *szMessage);

Parameters

szDigest
[out] to receive message digest.
szMessage
[in] containing the message to be hashed.

Returns (VBA/C)

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

szDigest 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]

[PREV: SHA2_Reset...]   [Contents]   [Index]   
   [NEXT: SHA3_AddBytes...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.