"""
return (n/d) + (n%d != 0)
-
class Encoder(object):
def __init__(self, k, m):
self.fec = fec.Encoder(k, m)
# padding
if len(l[-1]) != len(l[0]):
l[-1] = l[-1] + ('\x00'*(len(l[0])-len(l[-1])))
- return self.fec.encode(l)
-
- def decode(self, blocks):
- return self.fec.decode(blocks)
+ res = self.fec.encode(l)
+ return res
+class Decoder(object):
+ def __init__(self, k, m):
+ self.fec = fec.Decoder(k, m)
+
+ def decode(self, blocks, sharenums, padlen=0):
+ blocks = self.fec.decode(blocks, sharenums)
+ data = ''.join(blocks)
+ if padlen:
+ data = data[:-padlen]
+ return data
+