Adds an array of bytes to the digest.
Public Declare Function SHA3_AddBytes Lib "diCryptoSys.dll" (ByVal hContext As Long, ByRef lpData As Byte, ByVal nDataLen As Long) As Long
nRet = SHA3_AddBytes(hContext, abData(0), nDataLen)
long _stdcall SHA3_AddBytes(long hContext, const unsigned char *lpData, long nDataLen);
If successful, the return value is 0; otherwise it returns a non-zero error code.
Sha3.AddData Method (Byte[])
The handle to the context hContext must have been set up with a
prior call to SHA3_Init
. This function may be called many times before creating
the final message digest with SHA3_HexDigest
.
SHA3_AddString
may also be called.
This example creates the SHA-3-256 hash of the three-character string "abc" using a mixture of calls
to SHA3_AddBytes
and SHA3_AddString
.
Dim nRet As Long Dim nBytes As Long Dim strDigest As String Dim hContext As Long Dim abData(1) As Byte ' Set context handle hContext = SHA3_Init(256) ' Check for an invalid handle If hContext = 0 Then MsgBox "Failed to set context" Exit Function End If ' Set up a test array of bytes abData(0) = Asc("a") abData(1) = &H62 ' same as Asc("b") ' Add mixture of bytes and strings to pass "abc" nRet = SHA3_AddBytes(hContext, abData(0), 2) nRet = SHA3_AddString(hContext, "c") ' Get required length of output string (NB 2 times number of bytes) nBytes = SHA3_LengthInBytes(hContext) strDigest = String(nBytes * 2, " ") nRet = SHA3_HexDigest(strDigest, Len(strDigest), hContext) Debug.Print strDigest
This should result in output as follows:
3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532
SHA3_Init
SHA3_AddString
SHA3_HexDigest