Skip to content

Instantly share code, notes, and snippets.

@armaandhir
Created March 2, 2016 19:26
Show Gist options
  • Save armaandhir/0e87aa72571a4eae93b7 to your computer and use it in GitHub Desktop.
Save armaandhir/0e87aa72571a4eae93b7 to your computer and use it in GitHub Desktop.
simple crc check using python
def crc_encode(self, message, length):
new_message = message
crc = 0
hex_crc = 0x91
#lopp through each letter in string and store the xor value
for x in range(length):
crc ^= ord(message[x])
#loop through each bit in char and check if it
for y in range(8):
if(crc & 1):
crc ^=hex_crc
crc >>= 1
return chr(crc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment