Xceed Encryption Library Documentation
Examples / Hashing a file (VB streaming example)
    Hashing a file (VB streaming example)
    Visual Basic Copy Code

    ' This example hashes data using the SHA method from a file to memory in 8K (8192 byte) chunks. 

    Const CHUNKSIZE = 8192Dim xHash As New XceedHashing
    Call xHash.License( "your license key" ) 

    Dim lOffSet As Long
    Dim lFileSize As Long
    Dim lBytesRead As Long
    Dim vaHash As Variant 

    Set xHash.HashingMethod = New XceedSHAHashingMethod 

    lOffSet = 0 ' We must track the current offset 

    On Error Resume Next

    xHash.HashingMethod.HashSize = 256
    lFileSize = FileLen("c:\temp\source.txt") 

    While lOffSet < lFileSize
      'bEndOfData will be true if the current offset + CHUNKSIZE exceeds the end of the file. 
      lBytesRead = xHash.ReadFile("c:\temp\source.txt", lOffSet, CHUNKSIZE, efpHash, _
                                  (lOffSet + CHUNKSIZE >= lFileSize))  

      lOffSet = lOffSet + lBytesRead 
    Wend 

    If Err.Number = 0 Then
      MsgBox "Finished Hashing file to memory." 
      vaHash = xHash.HashingMethod.HashValue 
      ' Do something with the hash value... 
    Else
      MsgBox Err.Number & " " & Err.Description 
    End If

    On Error Goto 0 

    Set xHash = Nothing