Puedes revisar esta función
lcStr = "Cadena a comprobar"
?CheckSum(-1, lcStr, "16")
?Sys(2007, lcStr)
Function CheckSum (lnStartVal, lcBlockTxt, lcBitLen)
Do Case
Case Pcount() < 2
Wait Window "Se requieren parametros adicionales."
Return
Case Pcount() < 3
lcBitLen = "16"
Endcase
Dimension laPower[8]
Private lnCRC, lnPower, TestBit
lnBitLen = Iif(lcBitLen="32",32773,4129)
For lnPower = 1 To 8
laPower[lnPower] = 2^(lnPower-1)
Next lnPower
lnCRC = lnStartVal
For OutLoop = 1 To Len(lcBlockTxt)
ByteVal = Asc(Substr(lcBlockTxt, OutLoop, 1))
For InLoop = 8 To 1 Step - 1
TestBit = ((Bitand(lnCRC,32768) = 32768) And Not (Bitand(ByteVal, laPower(InLoop)) = laPower(InLoop))) Or;
(!(Bitand(lnCRC,32768) = 32768) And (Bitand(ByteVal, laPower(InLoop)) = laPower(InLoop)))
lnCRC = Bitand(lnCRC,32767)*2
If TestBit
lnCRC = Bitxor(lnCRC,lnBitLen)
Endif
Next InLoop
Next OutLoop
Return lnCRC && Return the Word Value
Function Xd0bit
Parameter Bitno, A
Private Remainder, I, Highord
Highord = Int(Iif(A>1,Log(A)*1.442695041,0))
If Bitno>Highord
Return .F.
Endif
For I = 0 To Highord
If I=Bitno
Return Iif(Iif(A=1,1,Mod(A,2))=1,.T.,.F.)
Endif
If A=0
Return .F.
Endif
A = Int(A/2)
Next
David Amador Tapia
WebMaster "La Web de Davphantom"
www.davphantom.net
Cartagena. Colombia