File: encode-decode.py

package info (click to toggle)
python-pyeclib 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,648 kB
  • sloc: python: 2,365; ansic: 982; sh: 136; makefile: 30
file content (29 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (3)
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
28
29
from __future__ import print_function
import platform
from pyeclib.ec_iface import ECDriver
import sys

# libisal2 is only available for amd64 and arm64 architectures
# Note: platform.machine() was returning 'x86_64' on an i386 machine so we
# also test sys.maxsize.
arch = platform.machine()
is64 = sys.maxsize > 2**32
if sys.argv[1].startswith('isa_') and (arch != 'x86_64' or not is64) and arch != 'aarch64':
    print("Skipping {} test for {} architecture, is64={}".format(sys.argv[1], arch, is64))
else:
    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")