The Reed-Solomon code allows the addition of codes in order to correct errors.
Reed Solomon |
Coding
The following is an outline:
import reedsolo import random import sys strin='Hello World' rs = reedsolo.RSCodec(10) str1=rs.encode(strin) print 'Input string:\t\t',strin print 'String after SR:\t',str1,'\nHex:',str(str1).encode("hex") print '\n=== 1 error===' i = random.randrange(0,len(str1)) str1=str1.replace(chr(str1[i]),'X',1) print 'String with error:\t',str1 print 'Corrected string:\t',rs.decode(str1) print '\n=== 2 errors===' i = random.randrange(0,len(str1)) str1=str1.replace(chr(str1[i]),'X',1) print 'String with error:\t',str1 print 'Corrected string:\t',rs.decode(str1) print '\n=== 3 errors===' i = random.randrange(0,len(str1)) str1=str1.replace(chr(str1[i]),'X',1) print 'String with error:\t',str1 print 'Corrected string:\t',rs.decode(str1) print '\n=== 4 errors===' i = random.randrange(0,len(str1)) str1=str1.replace(chr(str1[i]),'X',1) print 'String with error:\t',str1 print 'Corrected string:\t',rs.decode(str1) print '\n=== 5 errors===' i = random.randrange(0,len(str1)) str1=str1.replace(chr(str1[i]),'X',1) print 'String with error:\t',str1 print 'Corrected string:\t',rs.decode(str1)