Guest User

ELK M1 Gold CheckSum Calculator

a guest
May 29th, 2015
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. def calcElkCS(s):
  2.   """
  3.  Calculates checksum for sending commands to the ELKM1.
  4.  Sums the ASCII character values mod256 and takes
  5.  the lower byte of the two's complement of that value.
  6.  """
  7.   s = ('%02X' % (len(s) + 2)) + s
  8.   cs = '%2X' % (-(sum(ord(c) for c in s) % 256) & 0xFF)
  9.   return s+cs
Advertisement
Add Comment
Please, Sign In to add comment