Update 'Zadanie3'

This commit is contained in:
Klaudia Kandulska 2018-06-29 16:27:46 +00:00
parent 504f4a3c5a
commit 2ba847f726

View File

@ -85,37 +85,6 @@ def divide(message, poly16):
check = temp
return check
def decode(message,poly16,crc):
l_poly16 = len(poly16)
message = bytearray(message, 'ascii')
message = format(int.from_bytes(message, "big"), "b")
crc2=binascii.unhexlify(crc)
print(crc2)
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"
msg = "".join(obroc)
print(msg)
print(crc2)
remainder = divide(msg, poly16)
#Poprawione sprawdzanie
suma = 0
for i in range(0, len(remainder)):
if '1' in remainder:
suma = suma+1
if suma == 0:
print("true ")
elif suma > 0:
print("false")
def decode(message,poly16,crc):
l_poly16 = len(poly16)
message = bytearray(message, 'ascii')
@ -187,3 +156,4 @@ def main():
decode(sys.argv[1], poly16,sys.argv[3])
if __name__ == '__main__':
main()