Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Code example for file encode and decode #8

Open
MourIdri opened this issue Jan 5, 2018 · 2 comments
Open

Python Code example for file encode and decode #8

MourIdri opened this issue Jan 5, 2018 · 2 comments

Comments

@MourIdri
Copy link

MourIdri commented Jan 5, 2018

Hi team, I Saw your documentation for tahoe-fafs. The CLi seems to be well documented, however, regarding Python API it is a little bit short. Could you add an example of a small script of file encoding and decoding ?
Thanks.

@cllx
Copy link

cllx commented Jul 7, 2022

filefec.encode_to_files(inf, fsize, dirname, prefix, k, m, suffix=".fec", overwrite=False, verbose=False)

filefec.decode_from_files(outf, infiles, verbose=False)

@sajith
Copy link
Member

sajith commented Jul 7, 2022

Hi team, I Saw your documentation for tahoe-fafs. The CLi seems to be well documented, however, regarding Python API it is a little bit short. Could you add an example of a small script of file encoding and decoding ? Thanks.

Do the tests help? Like this one, for example:

zfec/zfec/test/test_zfec.py

Lines 114 to 128 in 612368e

def test_from_agl_py(self):
e = zfec.Encoder(3, 5)
b0 = b'\x01'*8 ; b1 = b'\x02'*8 ; b2 = b'\x03'*8
# print "_from_py before encoding:"
# print "b0: %s, b1: %s, b2: %s" % tuple(base64.b16encode(x) for x in [b0, b1, b2])
b3, b4 = e.encode([b0, b1, b2], (3, 4))
# print "after encoding:"
# print "b3: %s, b4: %s" % tuple(base64.b16encode(x) for x in [b3, b4])
d = zfec.Decoder(3, 5)
r0, r1, r2 = d.decode((b2, b3, b4), (1, 2, 3))
# print "after decoding:"
# print "b0: %s, b1: %s" % tuple(base64.b16encode(x) for x in [b0, b1])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants