File: encode-decode.py

package info (click to toggle)
python-pyeclib 1.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,604 kB
  • sloc: python: 2,266; ansic: 980; sh: 59; makefile: 48
file content (27 lines) | stat: -rw-r--r-- 616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import print_function
import platform
from pyeclib.ec_iface import ECDriver
import sys

# libisal2 is not available for non-amd64 architectures
arch = platform.machine()
if sys.argv[1].startswith('isa_') and arch != 'x86_64':
    print("Skipping {} test for {} architecture".format(sys.argv[1], arch))
    sys.exit(0)

input = b'test'

# Init
print("init:", end=" ")
ec = ECDriver(k=3, m=3, hd=3, ec_type=sys.argv[1])
print("OK")

# Encode
print("encode:", end=" ")
fragments = ec.encode(input)
print("OK")

# Decode
print("decode:", end=" ")
assert ec.decode(fragments[0:ec.k]) == input
print("OK")