Ive been hearing the term lately...whats a checksum? Is it something used to detect whether your program is being cracked or something??
Printable View
Ive been hearing the term lately...whats a checksum? Is it something used to detect whether your program is being cracked or something??
no, it goes on the end of something that verifies the data befoere it. If you look at ISBN numbers, you'll see the last number is 0-9 or X, that is the check digit which verifies the rest of it.
It's mainly used for inputting, when it will detect if you have entered any characters wrongly.
I believe it is used in a CRC.
Hmm i feel even stupidier than before...whats a CRC by the way?
ZIP files have it for that exact reason.
I dont mean to be a pain...but how do they work? If they're just a few chars at the end of some data then how can they verify the integrity of the entire thing?
The check sum is calulated by the value of each byte and their position therefore some simple packet like:
1234
will not have the same checksum as
4321
So what you do is to calcluate a check sum with the incoming data and see if that answer matchs the one sent in the packet.
For instance a real crappy check sum maker would be
For i = 0 to len
sum = sum + data(i) + (1024^i)
next i
Where data is an array of byte values.
HTH
G
Another crappy checksum, but you will get the idea:
VB Code:
Function Checksum(path As String) As Byte If len(Dir$(path)) Then Dim fnum As Long Dim ByteVar As Byte fnum = FreeFile Open path For Binary As #fnum While Not EOF(fnum) Get #fnum, , ByteVar 'Get a byte at a time as buffer was defined as a single byte Checksum = Checksum Xor ByteVar Wend Close #fnum End If End Function
I think it is faster to do this using asm and then implementing in VB.