Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CheckSum Logic 2

Status
Not open for further replies.

ufobaby

MIS
Sep 25, 2001
238
US
hi all,

is there a simple & efficient way of calculating a Check Sum ... i mean i do no want to use loop and stuff .. coz if the files are large performance issues arise.

could any API be a solution ?

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
i think that if u want to go through multiple records / text etc then a loop is unfortunately the only answer but somebody else may prove me wrong on this. I should imagine that u r bound by the rules of the computer on this, which means that to access different parts of information the computer must be told where to start, what to look for and where to finish. This brings u back to the loop. Sometimes there are built in functions 4 this but I am not aware of one in VB or VBA, I could be wrong though!
 
hi csniffer,

currently am using the Bitwise XOR, AND in a loop ....

Dear all,
in one of the posts i saw some CRYPTO API will be useful for this check sum thing .... i guess that would avoid the loop .. and would be faster

Suggestions please ....


__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
Yes, you could use an MD5 hash from the Crypto API. You should be able to pull the relevant code from the simple encrytion example I give in thread222-535644.

Alternatively, you could use the HashData API function from shlwapi, but see thread222-552692 for a discussion of the merits or otherwise of this.

Finally, since you seem to want a checksum for an entrie file, you might be interested in the MapFileAndCheckSum API call, eg:
[tt]
Option Explicit
Private Declare Function MapFileAndCheckSum Lib "imagehlp.dll" Alias "MapFileAndCheckSumA" (ByVal strFileName As String, ByRef HeaderSum As Long, ByRef CheckSum As Long) As Long
Private Const ERROR_SUCCESS = 0

Private Sub Command1_Click()
Debug.Print GetChecksum("c:\mytestfile.txt")
End Sub

' Returns 0 if file not found
Private Function GetChecksum(ByVal sFileName As String) As Long
Dim lHeaderSum As Long
Dim lCheckSum As Long
If MapFileAndCheckSum(sFileName, lHeaderSum, lCheckSum) = ERROR_SUCCESS Then GetChecksum = lCheckSum
End Function
 
thx a ton strongm,

this is a damm good and quick way of getting the check sum.... also a couple of questions.

1.] Where can i get a list of all the API functions, i have allapi.net 's API Guide but this isn't listed there.
also any book giving a good overview of the these ? am really looking forward for a good refrence on this ...

2.] Which one is better to use with large files the CRYPT function or the one u'v posted here.....

Thanks a ton once again.

__________
[cheers]
Niraj...
"The unexpected success is not just an opportunity for innovation. It demands innovation."
[noevil]
 
A general source of info on various APIs:


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks, Strongm. Good tip.


Real men don't use Interrupt 21h.
 
ufobaby,

I wish I could point you at one single, comprehensive list of the API functions in VB format. However, I can't. You've already found the site that most people seem to use and recommend (allapi).

The way I find them, often, is through trawling through the C/C++ header files that come with Visual Studio (sad, but true)
 
interesting stuff. Could a MD5 hash be used as a software key?

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top