forked from kalmar/DALGLI0
Update 'Zadanie3'
This commit is contained in:
parent
1dc92f3872
commit
9c6a607f34
6
Zadanie3
6
Zadanie3
@ -87,8 +87,12 @@ def decode(message,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")
|
||||||
|
while len(message) % 8 != 0:
|
||||||
|
message = "0" + message
|
||||||
dec = int(crc, 16)
|
dec = int(crc, 16)
|
||||||
crc2=bin(dec)[2:]
|
crc2=bin(dec)[2:]
|
||||||
|
while len(crc2) % 8 != 0:
|
||||||
|
crc2 = "0" + crc2
|
||||||
msg=message+crc2
|
msg=message+crc2
|
||||||
while len(msg) % 8 != 0:
|
while len(msg) % 8 != 0:
|
||||||
msg = "0" + msg
|
msg = "0" + msg
|
||||||
@ -153,4 +157,4 @@ def main():
|
|||||||
crc = argv[3]
|
crc = argv[3]
|
||||||
decode(sys.argv[1],sys.argv[3])
|
decode(sys.argv[1],sys.argv[3])
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user