Created
March 2, 2016 19:26
-
-
Save armaandhir/0e87aa72571a4eae93b7 to your computer and use it in GitHub Desktop.
simple crc check using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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