1: import array
2:
3: def checksum16(byteStrIn):
4: byteStringCpy = byteStrIn + bytes([0]* (len(byteStrIn)%2))
5: tmpArray = array.array("H", byteStringCpy)
6: tmpArray.byteswap()
7: cksum = sum(tmpArray)
8: cksum = (cksum >> 16) + (cksum & 0xffff)
9: cksum += (cksum >> 16)
10: return (~cksum) & 0xFFFF
PS: O código HTML foi gerado aqui!
1 comment:
*pokes*
"How to kill a brain with a single line of code":
http://ogatobranco.blogspot.pt/2009/06/line-of-code-of-day-3.html
Yep... bons tempos...
Post a Comment