Creates a SHA-1 message digest in Byte array format from a message in Byte array format.
VB6/VBA
Debug.Print "Testing SHA1_BytesHash ..." Dim nRet As Long Dim abData(2) As Byte ' Create 3-byte array (NB zero-based) Dim abDigest(19) As Byte ' Create 20-byte array to receive digest Dim i As Integer ' Setup byte array with "abc" abData(0) = Asc("a") abData(1) = Asc("b") abData(2) = Asc("c") ' Compute SHA-1 hash digest of input nRet = SHA1_BytesHash(abDigest(0), abData(0), 3) ' Now carry out repeated hashes of the digest For i = 2 To 1000 nRet = SHA1_BytesHash(abDigest(0), abDigest(0), 20) Next ' Print H(1000) in hex format Debug.Print cnvHexStrFromBytes(abDigest)
Output
Testing SHA1_BytesHash ... 58EEDCE24AD638F2ABF39E4B13D5726802DEF2C1
VB.NET
Console.WriteLine("Testing SHA1_BytesHash ...")
''Dim nRet As Integer
Dim abData(2) As Byte ' Create 3-byte array (NB zero-based)
''Dim abDigest(19) As Byte ' Create 20-byte array to receive digest
Dim abDigest() As Byte
Dim i As Integer
' Setup byte array with "abc"
abData(0) = Asc("a")
abData(1) = Asc("b")
abData(2) = Asc("c")
' Compute SHA-1 hash digest of input
abDigest = Sha1.BytesHash(abData)
' Now carry out repeated hashes of the digest
For i = 2 To 1000
abDigest = Sha1.BytesHash(abDigest)
Next
' Print H(1000) in hex format
Console.WriteLine(Cnv.ToHex(abDigest))
[Contents]