def test_hamming(): print("Testing Hamming") h = Hamming(3) my_str = "111100001010" e = h.encode(my_str) print("original string: ", my_str) print("original encoded: ", e) e = e[:-1] + "1" e = "0" + e[1:] print("errored encoded: ", e) d = h.decode(e) print("decoded string: ", d)
def test_hamming_multiple_block_encode_only(): ham = Hamming(block_size=16) in_block = bytearray(b"e") bits = ham.encode(in_block) assert len(bits) == 2
from hamming import Hamming data = raw_input('Type the message you to send: ') h = Hamming() print 'The message to be sent with ' + str( h.calculateR(data)) + ' redudancy bits is: ' + h.encode(data)