Zadanie3 #28

Closed
s407228 wants to merge 18 commits from s407228/DALGLI0:Zadanie3 into master
Showing only changes of commit 066de73659 - Show all commits

View File

@ -84,21 +84,24 @@ def divide(message, poly16):
check = temp
return check
def decode(message_final,poly16,crc):
def decode(message,poly16,crc):
l_poly16 = len(poly16)
appended_message2 = toBinary(message_final)
obroc = list(appended_message2)
message = bytearray(message, 'ascii')
message = format(int.from_bytes(message, "big"), "b")
dec = int(crc, 16)
crc2=bin(dec)[2:]
msg=message+crc2
while len(msg) % 8 != 0:
msg = "0" + msg
obroc = list(msg)
for i in range(l_poly16 - 1):
if obroc[i] == "0":
obroc[i] = "1"
elif obroc[i] == '1':
obroc[i] = "0"
appended_message2 = "".join(obroc)
msg = "".join(obroc)
dec = int(crc, 16)
crc2=bin(dec)[2:]
msg=appended_message2+crc2
remainder = divide(msg, poly16)
#Poprawione sprawdzanie
suma = 0
@ -137,7 +140,6 @@ def encode(message, poly16):
print("calosc : ", message_final)
print("crc : ", ab)
poly16 = "10001000000100001"
def main():