#include once "window9.bi"

function FastCRC16(byval buffer as any ptr, byval nSize as uinteger) as ushort export
	if buffer=0 then return 0
	if nSize =0 then return 0
	dim as ubyte ptr p = buffer
	dim as ushort CRC = &HFFFF
	for i as integer=1 to nSize
		CRC xor= *p : p+=1
		for j as integer=1 to 8 ' 8 bits
			CRC = iif(CRC and 1,(CRC shr 1) xor &HA001,CRC shr 1)
		next
	next
	return CRC
end function

