1
0
forked from kalmar/DALGLI0

Update 'Zadanie3'

This commit is contained in:
Klaudia Kandulska 2018-06-29 16:26:06 +00:00
parent c624158b50
commit 504f4a3c5a

View File

@ -89,8 +89,8 @@ def decode(message,poly16,crc):
l_poly16 = len(poly16) l_poly16 = len(poly16)
message = bytearray(message, 'ascii') message = bytearray(message, 'ascii')
message = format(int.from_bytes(message, "big"), "b") message = format(int.from_bytes(message, "big"), "b")
dec = int(crc, 16) crc2=binascii.unhexlify(crc)
crc2=bin(dec)[2:] print(crc2)
msg=message+crc2 msg=message+crc2
while len(msg) % 8 != 0: while len(msg) % 8 != 0:
msg = "0" + msg msg = "0" + msg
@ -171,7 +171,8 @@ def encode(message, poly16):
message_final = bytearray(message_final, 'ascii') message_final = bytearray(message_final, 'ascii')
d = bytearray(d, 'ascii') d = bytearray(d, 'ascii')
print("calosc : ", message_final) print("calosc : ", message_final)
print("crc : ", d) print("crc hex : ", ab)
print("crc ascii : ", d)
poly16 = "10001000000100001" poly16 = "10001000000100001"