Computes the checksum for a range of bytes
b = CheckSumByte(addr%, count%, [old])
b, old: byte expression
addr, count: integer expression
The function CheckSumByte() calculates a simple checksum for a block of data: count bytes from the address addr. The optional parameter old is to be used if you want to create a checksum for more than one block, old must contain the checksum for the other block.
The checksum is a simple adding of 8-bit values (bytes) in the data.
Local a$, b$, ch_a|
Debug.Show
a$ = "This is a test"
b$ = "another block"
ch_a| = CheckSumByte(V:a$, Len(a$))
Trace CheckSumByte(V:a$, Len(a$)) // 249
Trace CheckSumByte(V:b$, Len(b$)) // 33
Trace CheckSumByte(V:a$, Len(a$), ch_a|) // 243
The calculation of data with CheckSumByte, CheckSumShort, CheckSumLong (or CheckXorxxx()) is very fast (up to 10 times faster than Crc16() or Crc32()).
A checksum is a form of redundancy check, a simple way to protect the integrity of data by detecting errors in data that are sent through space (telecommunications) or time (storage). It works by adding up the basic components of the data, typically the asserted bits, and storing the resulting value. Anyone can later perform the same operation on the data, compare the result to the authentic checksum, and (assuming that the sums match) conclude that the data was probably not corrupted.
CheckSumByte(), CheckSumLong(), CheckSumShort(), CheckXorByte(), CheckXorLong(), CheckXorShort(), Crc16(), Crc32()
{Created by Sjouke Hamstra; Last updated: 25/09/2014 by James Gaite}