I found an API call that simplifies the Hash process by combining several steps into one:
http://www.vbforums.com/showthread.p...017-VB6-Hash10
It only works with Win 10, and I was curious if there was a performance advantage. So I hashed a 7,042 KB file several times with the old process, and with the newer process on the same Win 10 machine. The average time taken with the old process was 0.101 seconds, compared to 0.065 seconds with the newer process. I cannot explain why, but there does seem to be an advantage to using the newer process when it is available. That would mean being able to detect if the newer call was supported. So I came up with this:
Is there a better way to accomplish this?
J.A. Coutts
http://www.vbforums.com/showthread.p...017-VB6-Hash10
It only works with Win 10, and I was curious if there was a performance advantage. So I hashed a 7,042 KB file several times with the old process, and with the newer process on the same Win 10 machine. The average time taken with the old process was 0.101 seconds, compared to 0.065 seconds with the newer process. I cannot explain why, but there does seem to be an advantage to using the newer process when it is available. That would mean being able to detect if the newer call was supported. So I came up with this:
Code:
On Error Resume Next
'Test if Win 10 API supported using dummy call
Call BCryptHash(0&, 0&, 0&, 0&, 0&, 0&, 0&)
If Err = 453 Then 'Use original API cslls
bHash = HashData(StrPtr(HashAlg), bBuffer)
Else 'Use Win 10 Calls
bHash = Hash10Data(StrPtr(HashAlg), bBuffer)
End If
J.A. Coutts